Comment on page
This section explains how to use MyEtherWallet and Metamask to perform an ABI transaction in the Eco Protocol. ABI transactions allow users to submit transactions to the Ethereum network for functions in the Eco Protocol where no Web Application exists.
2) MyEtherWallet allows you to connect your wallet to submit transactions using a graphical interface that uses an "ABI", which stands for "Application Binary Interface". This tells your wallet which functions are available for a given smart contract, and how to structure the inputs. Click on the "Access my wallet" button.
3) Select the wallet you use. For this tutorial, we will use the popular Metamask wallet. This should display the below interface. If you don't see the "Interact with Contract" interface, it is accessible under the "Contract" sidebar.
4) The "Interact with Contract" function asks for a contract and for an ABI interface. To get the contract, we will query the "Root Policy Address", but first we will need a detour to get the ABI documents.
5) This will require a GitHub account and we will clone the main Eco Currency repo, and build the ABI files. Open a terminal, and paste the following instructions in the terminal.
git clone https://github.com/helix-foundation/currency.git
6) This should succeed, and should show that Solidity files are built. The built solidity files contain the ABI you need to interact with the contract. The ABIs will be located in the currency folder you cloned under the path
7) We will first call the root policy contract to determine where the ECOx and
ECOxStakingcontract is. To find the policy ABI, navigate to
artifacts/contracts/policy/Policy.sol/Policy.jsonand open the file.
8) Copy everything from the file after
"abi":and up to
"bytecode":and delete the comma at the end. Paste this into the ABI section on MyEtherWallet.
9) Paste in the root policy address (0x8c02D4cc62F79AcEB652321a9f8988c0f6E71E68), and press interact with contract.
10) Navigate to the drop-down menu, and select the
PolicyForfunction. The input uses the ERC1820 register to look up where active functions are.
11) An easy way to calculate the hash to put in "_interfaceIdentifer input" is this online tool to hash the contract name you are looking for. Putting in "ECOx" yields
e10ab6c94f1da69921a0ca1c1b96b4fc339699153931c9bfd565e91f44c19b0bwhich we put in the input field of the interface.
12) Call the function. The output is the address of the ECOx contract we are looking for. Record this contract address.
13) We are also going to get the address of the
ECOxStakingcontract. Using the same process, we get the hash of
14) Recall the function with the new hash. Also, record this contract address.
15) We now need to approve the ECOx transfer to the staking contract and stake the ECOx.
16) We are going to interact with the ECOx contract first. Exit out of the interface for this contract, and load in the contract address and ABI for the ECOx contract. The ABI is located at
17) Using this ABI, we are going to call the
Approvefunction. This transaction gives the staking address permission to transfer your ECOx.
spenderaddress is the
ECOxStakingcontract address from step #14.
amountis the amount of ECOx units you want to stake. ECOx has 18 decimals, meaning that 1 unit of ECOx is represented by
20) Write the transaction, and approve it in Metamask. Once confirmed, we can move to the
21) Exit this interface, and load up the
ECOxStakingcontract. The ABI is located at
22) We are going to call the
Depositfunction. This is the final step to stake your ECOx in the staking contract!
23) Call the
Depositfunction with the value you approved from step #19. Write the transaction and approve it in MetaMask.
24) Once the transaction confirms, you're done! If you would like to track the amount of Staked ECOx in your wallet, navigate to the staking transaction on Etherscan, and find the s-ECOx token in the transaction information. Use its contract address to add it to your MetaMask.
25) Note, s-ECOx is not transferable. To withdraw the ECOx, simply call the
Withdrawfunction in using the
ECOxStakingABI, with the same value you deposited!
Hopefully, this guide was a helpful example of how ABIs can be used to directly interact with a contract!