A typical ERC20 transfer on the Ethereum mainnet takes $1. Making a transfer of a token whose value is in cents and paying $1 as transaction fess is not at all economical. Therefore, we needed to find a way to pay minimal transaction fees to provide value in our reward for community input, or let me put this way:
Total value of tokens transferred in a single transaction > Transaction Fee.
- Implementation of wallet accounts based on hierarchy mapping and configuration choices
- Adding events to contracts like expenses, given/received discounts, sponsorships (match% in $s, items, hours), coupons, points, revenue from other individuals/groups
- One main challenge was to show the visual map of disbursements for all funds came from inside activity and left an activity wallet. Solved this problem using the D3.js library.
- To create robust APIs to be integrated with any mobile app
After going through the above problem statement and a series of discussions with the internal blockchain team at V2Soft and the client, we decided that an approach of Bulk Transfer would maintain the value of the reward.
While creating a solution for one of our clients (OpenTherapoid), wherein we (V2Soft) were responsible for creating an ERC20 contract and enable token transfers from the contract to different user addresses.
The user was being rewarded with ScienceCoins for different activities that they perform on the OpenTherapoid platform.
First, what is Bulk Transfer?
Bulk Transfer is a mechanism or a function that has been coded in the smart contract which takes in an array of accounts (multiple accounts), along with an array of amounts (amount for each account), and an array of activities (activity for each account), which internally loops through these arrays and transfers the amount from the amounts array to the account from the accounts array and logs the activity from the activities array.
We were surprised by the reduction in the amount of gas that was consumed for each transfer.
We have analyzed the gas used by Single Transfer Vs BulkTransfer
|Type||Gas Price||Tx Fee||Rinkeby Tx URL|
|Single Transfer||0.000000002||0.000070802||Single Transfer|
|Bulk Transfer||0.000000002||0.000205656||Bulk Transfer|
Points worth noting are as follows:
- Gas used by Single Transfer 35401
- In terms of dollar amounts, the Tx price for Single Transfer (as per our observation on Testnet) is $0.14, thus six individual transfers would have costed 0.14 * 6 = $0.84
- In terms of gas used by Single Transfer (as per our observation on Testnet) is 35401, thus six individual transfers would have used 35401 * 6 = 212406
- Gas used by Bulk Transfer 102828 (6 Token Transfers were done inside one transaction)
- In terms of dollar amount, the Tx price for BulkTransfer (as per our observation on Testnet) is $0.41
- In terms of gas used by Single Transfer (as per our observation on Testnet) is 102828
|Type||Tx Fee In $||Gas Used|
It is evident that processing token transfers individually is not economical in the long run whereas processing token transfers using a bulk approach is economical and these are supported by the above findings.