register_algo_chain.js 961 B

1234567891011121314151617181920212223242526272829303132
  1. // run this script with truffle exec
  2. const jsonfile = require("jsonfile");
  3. const TokenBridge = artifacts.require("TokenBridge");
  4. const TokenImplementation = artifacts.require("TokenImplementation");
  5. const BridgeImplementationFullABI = jsonfile.readFileSync(
  6. "../build/contracts/BridgeImplementation.json"
  7. ).abi;
  8. const algoTokenBridgeVAA = process.env.REGISTER_ALGO_TOKEN_BRIDGE_VAA;
  9. module.exports = async function(callback) {
  10. try {
  11. const accounts = await web3.eth.getAccounts();
  12. const initialized = new web3.eth.Contract(
  13. BridgeImplementationFullABI,
  14. TokenBridge.address
  15. );
  16. // Register the ALGO endpoint
  17. await initialized.methods
  18. .registerChain("0x" + algoTokenBridgeVAA)
  19. .send({
  20. value: 0,
  21. from: accounts[0],
  22. gasLimit: 2000000,
  23. });
  24. callback();
  25. } catch (e) {
  26. callback(e);
  27. }
  28. };