Exploring transfer steps and estimating the gas cost
Author: Louise Linné 2021-05-06
This tutorial is made for finding the transfer steps that the circles api would chose to make a hypothetical transitive transaction. It also explains how to find the estimated gas cost.
#To find the transfer steps you will need:
- A circles account with enough circles
- The checksummed* safe address of that account (you can find it in your circles wallet under Settings as "Profile address")
- The checksummed* address of another account you want to transfer to
#To estimate the gas cost you will also need:
- A metamask account connected to the first circles account
- You can follow this guide
- Switch from Ethereum mainnet to the xDai network. To add xDai chose custom RCP under Networks and specify the following:
- name: xdai
- URL: https://xdai.poanetwork.dev
- Chain ID: 100
*A checksummed address will contain some capital letters unlike the non-checksummed address.
- Decide on a transfer:
- from whom (use an account you have access to)
- to whom
- how many circles
- Find the transfer steps
Run this command in the terminal with your specified data
This is what the circles.garden wallet calls to find out how much you can send to an account when doing a transaction through the app. It uses a large amount of circles to get the maximum amount: 1 000 000 000 000 000 000 000 000 000 000 000 Wei = 1 trillion circles. (1 Circle is 1 000 000 000 000 000 000 Wei)
The result will look something like this:
- Extract data arrays specifying the transfers
Use a script like this to extract arrays of
Then remove white spaces and make sure quotations are double quotations.
- Get the hex data for the transaction
Now that you have the lists of
amounts, go to the circles Hub on blockscout.
In the "Write Contract" tab:
- connect to your metamask account
- use "3.transferThrough" and paste the value arrays from above
- click "write"
- Metamask will open, switch to the data tab and copy the hex data
- Get the gas estimates from the circles api
Running this curl command (it needs the checksummed safe address, which you can find it in your circles wallet and the hex data)
returns the gas information like this:
The total gas is
safeTxGas + baseGas. In the example above, the total gas is then
4.159.332 (which under the
12.500.000 gas per block limit).
The gas price is specified in Wei and is constant on the xDai network.