Deploying a smart contract on BPX mainnet using Remix IDE
- Open
theRemix IDE.
2. In our example, we will use one of the test smartsample contracts that is already uploaded intofrom the IDE. Open contracts/1_Storage.sol file.
On the right you can see the contract source code. This contract provides two functions.functions: Thethe firstfirst, (store
), allows you to save any number in the contract, andwhile the secondsecond, (retrieve
), allowsenables you to read it.the stored number. Open the contracts/1_Storage.sol
file.
3. Compile the contract by right-clicking on the file name,name thenand selectselecting Compile.
4. When the source code doesis not contain any errorserror-free and the 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 MetamaskMetaMask will askprompt you for permission to connect to the Remix IDE. Agree to connect.the connection.
8. After successfully connecting, you should see your account address and its balance in the markedhighlighted field.
9. Click "Deploy" to startbegin deploying your contract. Confirm the suggested gas settings.
10. In the MetamaskMetaMask popup window, change the gas settings by clicking on "Site suggested," then select the "Market" option. ThenAfter that, confirm the transaction.
11. Your contract is now deploying. If you open the MetamaskMetaMask window, you should see thea new pending transaction.
12. Once the transaction is confirmed by the blockchain, you will see its confirmation and a new itementry in the Deployed Contracts section. Your contract ishas been successfully deployed.
13. You can use the markedhighlighted button to copy the address of your new contract to interact with it in the future.contract.
14. Now youYou can testinteract with your contract directly from the contract by calling its functions.IDE. Expand the list of contract methods.methods to access them.
15. Let's call the first function (store
) to save anya number in theour sample contract. Enter a random number in the text field next to the "store" button.button, Thenand then press the "store" button.
16. Confirm the transaction in your wallet inas theyou same way asdid 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 functionmethod (retrieve
) to read the number stored in the smart contract. Click the "retrieve" functionbutton, button.and Thethe blockchain will return the value stored in the contract.