Distribution contract is an ethereum counterpart of our distribution service. It is very simple and has only one method. This method is involved by our system to distribute tokens to several recipients in a single call and thus, save gas fees.
Neither distribution smart contract nor account of the contract owner do not store tokens. Tokens must be stored on a separate account that will provide allowance for contract address to distribute tokens on his behalf.
Guide below as well as distribution contract is designed for dock token, however, one can easily substitute dock token with any other ERC20 contract.
- Open dock contract code (https://github.com/dockio/dock-token/blob/master/crowdsale.sol)
- Make sure to have Holder account opened in Metamask and switch to MainNet (one that has a lot of tokens that will be allowed to be spent)
- Open remix (https://remix.ethereum.org) and paste dock token contract there
- Select
Run
tab - Select
DockToken
from the list of available contracts - In "Load from address" field enter dock token address.
- Click "At address". You will see contract loaded underneath
- Find red button "approve", in field next to it enter
"<Distribution address>", <amount>
, ie"0xab31fe0f8c1e7d1a11fd89adec18652e53417936", 1045050000000000000000000
which will allow 1045050 tokens to be spent by 0xab31fe0f8c1e7d1a11fd89adec18652e53417936 address. Notice 18 zeros. They are required and are equal to dock token decimals. - Hit red "approve" button, verify transaction details and approve it via MetaMask.
- Wait for transaction to be mined and verify proper allowance.
- Open dock token in EtherScan: https://etherscan.io/token/0xe5dada80aa6477e85d09747f2842f7993d0df71c#readContract
- Select "Read Contract"
- In "Allowance" enter Holder address, Distribution address (address of the distributed "Distribution" contract) and hit "Query"
- You should see number of allowed tokens. Divide that number by 10^18 to get token amount.
In order to deploy contract directly from Remix one should:
- Open MetaMask plugin, select proper network and proper account
- Load remix from https://remix.ethereum.org
- Load required files
- On the right select
Run
tab - Make sure that environment is set to be
Injected Web3
(that is one, provided by MetaMask) - Make sure proper account is selected
- Select proper contract and provide proper constructor attributes
- Hit Create and confirm transaction in MetaMask.
- Wait for the magic to happen.