ERC1820 is a contract that is considered a special case since it requires a few modifications in order to work on VeChain. It is used by ERC777 so failure in ERC1820 inevitably results in failure in ERC777 also. The changes required for deploying ERC1820/ERC777 on testnet were the following:
Chain Tag
Contract Owner address
Contract address passed in constructor
Remove gas fee limitation
Chain Tag
The first change that we have to do is change the chain-tag of the transaction creating the contract from 0(?) to 27(?). Since the contract exists in a compiled form under openzeppelin-contracts/node_modules/@openzeppelin/test-helpers/src/data.js we had to change the binary in that file alongside the address. The two lines that were changed can be seen below:
We generated the ERC1820_REGISTRY_DEPLOY_TX by using the following test in thor to generate the hex string version of the transaction with the new chain tag. We also had to use the relevant command to query thor to give us the ERC1820_REGISTRY_ADDRESS. Once we had that we updates the two lines in the node module.
Contract address passed in constructor
The last change that we need to do is in ERC777SenderRecipientMock.sol and ERC777.sol respectively. In both cases we changed the line that instantiates IERC1820Registry by changing to the correct contract address.
We had to remove any gas limits that were present in our hardhat.config.js file. With these changes one can deploy ERC1820 on testnet.
ERC777 Specifics
Timeout Increase
For running ERC777.test.js on testnet we also had to make one final change. First, In the modules.export section in the hardhat.config.js add the following line to increase the timeout limit.
mocha: { timeout:180000 },
Account Funding
In order to successfully run the tests all 10 accounts that are derived from your seed should be appropriately funded with VTHO. For our ERC777 test we required around 10000 VTHO in the first account and at least a few hundred in all the other 9. An easy way to obtain a large amount of testnet VTHO is to use the testnet faucet and then convert your VET to VTHO using the energy station. You will need to use the Sync2 client and create a new testnet wallet in order to be able to do this.