nervosnetwork / polyjuice-provider

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

truffle deploy contract failed #92

Open milescui opened 2 years ago

milescui commented 2 years ago

I have tried a lot, and the last step always has an error.

@polyjuice-provider/truffle version: 0.1.3

Starting migrations...
======================
> Network name:    'godwoken'
> Network id:      71394
> Block gas limit: 531500000 (0x1fae0be0)

1_initial_migration.js
======================

   Replacing 'Migrations'
   ----------------------
   > transaction hash:    0x5f21b14510c9a9df5188891d6f2926fb4387d69e03c5487b1ce50e9bafcede22
   > Blocks: 1            Seconds: 12
   > contract address:    0x2f6cB3E28b37183DF0F8b59b0c532cFC8C734d45
   > block number:        146240
   > block timestamp:     1646300389
   > account:             0xaDb8860D7426e15FCE11a5d17C8A10Db8E7cD54b
   > balance:             0
   > gas used:            20946 (0x51d2)
   > gas price:           0 gwei
   > value sent:          0 ETH
   > total cost:          0 ETH

   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:                   0 ETH

2_deploy_contracts.js
=====================

   Deploying 'StringUtil'
   ----------------------
   > transaction hash:    0xb40bb531d6f471c79db0d8fecb8a01230c9a0e4ca3411859a650613f67085462
   > Blocks: 0            Seconds: 0
   > contract address:    0x948A704c94387D8f78474f5392E43Ef191e75c8B
   > block number:        146241
   > block timestamp:     1646300460
   > account:             0xaDb8860D7426e15FCE11a5d17C8A10Db8E7cD54b
   > balance:             0
   > gas used:            316 (0x13c)
   > gas price:           0 gwei
   > value sent:          0 ETH
   > total cost:          0 ETH

   Deploying 'TransferHelper'
   --------------------------
   > transaction hash:    0x02d9943845791c42ea0cee89b86e9705fb3ca5898e304967ef347765481532e8
   > Blocks: 0            Seconds: 0
   > contract address:    0xA60B91ed3769269b53bC8de917e0e7bd8075938c
   > block number:        146242
   > block timestamp:     1646300541
   > account:             0xaDb8860D7426e15FCE11a5d17C8A10Db8E7cD54b
   > balance:             0
   > gas used:            97 (0x61)
   > gas price:           0 gwei
   > value sent:          0 ETH
   > total cost:          0 ETH

   Linking
   -------
   * Contract: OrderService <--> Library: StringUtil (at address: 0x948A704c94387D8f78474f5392E43Ef191e75c8B)

   Deploying 'OrderService'
   ------------------------
   > transaction hash:    0x0cb4f1a6ee3d45703f32981363a567cfd8ac0f2e6dbaf5af6971b35e2ee013e9

Error:  *** Deployment Failed ***

"OrderService" -- Transaction was not mined within 750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!.

    at /usr/local/Cellar/truffle/5.4.9/libexec/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at Migration._deploy (/usr/local/Cellar/truffle/5.4.9/libexec/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:70:1)
    at Migration._load (/usr/local/Cellar/truffle/5.4.9/libexec/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:56:1)
    at Migration.run (/usr/local/Cellar/truffle/5.4.9/libexec/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:217:1)
    at Object.runMigrations (/usr/local/Cellar/truffle/5.4.9/libexec/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
    at Object.runFrom (/usr/local/Cellar/truffle/5.4.9/libexec/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
    at Object.runAll (/usr/local/Cellar/truffle/5.4.9/libexec/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:114:1)
    at Object.run (/usr/local/Cellar/truffle/5.4.9/libexec/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:79:1)
    at runMigrations (/usr/local/Cellar/truffle/5.4.9/libexec/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:258:1)
    at Object.run (/usr/local/Cellar/truffle/5.4.9/libexec/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:223:1)
    at Command.run (/usr/local/Cellar/truffle/5.4.9/libexec/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:172:1)
Truffle v5.4.9 (core: 5.4.9)
Node v14.13.1

truffle-config.js

const { PolyjuiceHDWalletProvider } = require('@polyjuice-provider/truffle');
const { PolyjuiceHttpProvider } = require('@polyjuice-provider/web3');

const PRIVATE_KEY = process.env.PRIVATE_KEY;

const polyjuiceConfig = {
    web3Url: 'https://mainnet.godwoken.io/rpc/eth-wallet',
};

const polyjuiceHttpProvider = new PolyjuiceHttpProvider(polyjuiceConfig.web3Url, polyjuiceConfig);

module.exports = {
    compilers: {
        solc: {
            version: '0.8.7', // Fetch exact version from solc-bin (default: truffle's version)
            settings: {
                optimizer: {
                    enabled: true,
                    runs: 2000,
                },
            },
        },
    },

    networks: {
        godwoken: {
            provider: function() {
                return new PolyjuiceHDWalletProvider(
                    [
                        {
                            privateKeys: [PRIVATE_KEY],
                            providerOrUrl: polyjuiceHttpProvider,
                        },
                    ],
                    polyjuiceConfig,
                );
            },
            network_id: '71394',
            // notice: `gasPrice: 0` won't work in dryRun mode. 0 must be string type.
            gasPrice: '0',
        },
    },
};
e00dan commented 2 years ago

@milescui

On mainnet beta you can only deploy if your address is whitelisted. You can apply for whitelisting here: https://share.hsforms.com/1TtzKmmjMR1ayq9vYF9G3dgcadup

You can freely deploy on testnet.

milescui commented 2 years ago

Thank you for your reply. I have successfully deployment the contract in the mainnet. However, I have encountered new problems.

I will transfer token to the newly deployed contract with yokaiswap L2 Transfer, prompting me that the uninitialized recipient account.

contract address: 0x61992C7DCc4DBa27FD6fCFACC7f09E8A8ec24314