Deploying smart contract on BPX mainnet using Remix IDE
- Open the Remix IDE.
2. In our example, we will use one of the test smart contracts that is already uploaded into the IDE. Open contracts/1_Storage.sol
file.
On the right you can see the contract source code. This contract provides two functions. The first (store
) allows you to save any number in the contract, and the second (retrieve
) allows you to read it.
3. Compile the contract by right-clicking on the file name, then select Compile.
4. When the source code does not contain any errors and compilation is successful, you will see a green success icon.
5. Go to the Deploy tab.
6. Expand the Environment list and select Injected Provider - MetaMask.
7. Now Metamask will ask you for permission to connect to the Remix IDE. Agree to connect.
8. After successfully connecting, you should see your account address and its balance in the marked field.
9. Click Deploy to start deploying your contract. Confirm the suggested gas settings.
10. In the Metamask popup window, change the gas settings by clicking on Site suggested, then select the Market option. Then confirm the transaction.
11. Your contract is now deploying. If you open the Metamask window, you should see the new pending transaction.
12. Once the transaction is confirmed by blockchain, you will see its confirmation and a new item in the Deployed Contracts section. Your contract is deployed.
13. You can use the marked button to copy the address of your new contract to interact with it in the future.
14. Now you can test the contract by calling its functions. Expand the list of contract methods.
15. Let's call the first function (store
) to save any number in the contract. Enter random number in the text field next to the store button. Then press the store button.
16. Confirm the transaction in your wallet in the same way as when deploying the contract. Saving data to a smart contract requires a transaction on the blockchain.
17. When the transaction is confirmed, call the second function (retrieve
) to read the number stored in the smart contract. Click the retrieve function button. The blockchain will return the value stored in the contract.
No Comments