nervosnetwork / polyjuice-provider

Godwoken-Polyjuice compatible providers for ethereum library
https://www.npmjs.com/org/polyjuice-provider
8 stars 13 forks source link

deploy contract failed #90

Closed vdovaT closed 2 years ago

vdovaT commented 2 years ago

deploy code:

  const implementationFactory = new ContractFactory(
    pool.abi,
    pool.bytecode,
    deployer
  );

  const deployArgs = [
    "0x3e94373E48fBdaC9AbD0450Fe358a2C3c739A850", // Owner
    [
      "0x91d43eD61bA314F0cbfBd43F280e2C33B3d0C1ee",
      "0x48dc3f7a68D6B34d266642Ae6525517D45CE24B7",
      "0x7F4781A67D5b0e57caD4931192871F38f454Cb13",
      "0x81F7Ec1dC3a48d63AaeEF0835ef2E607F05Bfbf2",
    ],
    "0xa390E597f78d0A4f6149094C8F952f433C47fcCF", // pool_token
    200,
    4000000,
    5000000000,
  ];
  // you need the following step to convert the deployArgs before deploying contract:
  const newDeployArgs = await deployer.convertDeployArgs(
    deployArgs,
    pool.abi,
    pool.bytecode
  );

abi:

    {
      "outputs": [],
      "inputs": [
        { "type": "address", "name": "_owner" },
        { "type": "address[]", "name": "_coins" },
        { "type": "address", "name": "_pool_token" },
        { "type": "uint256", "name": "_A" },
        { "type": "uint256", "name": "_fee" },
        { "type": "uint256", "name": "_admin_fee" }
      ],
      "stateMutability": "nonpayable",
      "type": "constructor"
    }

error:

Error: script.code_hash must be a hex string!
    at Godwoker.getShortAddressByAllTypeEthAddress (/Users/orange/Documents/personal/lumo-contracts/node_modules/@polyjuice-provider/base/lib/util.js:547:19)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async /Users/orange/Documents/personal/lumo-contracts/node_modules/@polyjuice-provider/base/lib/util.js:905:38
    at async Promise.all (index 0)
    at async convertContractConstructorArgs (/Users/orange/Documents/personal/lumo-contracts/node_modules/@polyjuice-provider/base/lib/util.js:899:25)
    at async PolyjuiceWallet.convertDeployArgs (/Users/orange/Documents/personal/lumo-contracts/node_modules/@polyjuice-provider/ethers/lib/wallet-signer.js:46:31)
    at async main (/Users/orange/Documents/personal/lumo-contracts/scripts/deploy.js:45:25)
jjyr commented 2 years ago

Are you using the latest version?

RetricSu commented 2 years ago

can you try adding this line before deployment?

    await deployer.godwoker.init();
vdovaT commented 2 years ago

can you try adding this line before deployment?

    await deployer.godwoker.init();

worked, thx!