mkdir MegaCoin
cd MegaCoin
const HDWalletProvider = require('@truffle/hdwallet-provider');
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();
module.exports = {
networks: {
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 8545, // Standard BSC port (default: none)
network_id: "*", // Any network (default: none)
},
testnet: {
provider: () => new HDWalletProvider(mnemonic, `https://data-seed-prebsc-1-s1.binance.org:8545`),
network_id: 97,
confirmations: 10,
timeoutBlocks: 200,
skipDryRun: true
},
bsc: {
provider: () => new HDWalletProvider(mnemonic, `https://bsc-dataseed1.binance.org`),
network_id: 56,
confirmations: 10,
timeoutBlocks: 200,
skipDryRun: true
},
},
// Set default mocha options here, use special reporters etc.
mocha: {
// timeout: 100000
},
// Configure your compilers
compilers: {
solc: {
version: "^0.6.12", // A version or constraint - Ex. "^0.5.0"
}
}
}
請注意,它需要為 Provider 傳遞助記詞,這是您要部署的帳戶的助記詞。 在根目錄中創建一個新的 .secret 文件並輸入您的 12 字助記詞助記詞以開始使用。 要從 metamask 錢包中獲取種子詞,您可以轉到 Metamask 設置,然後從菜單中選擇安全和隱私,您將在其中看到一個顯示種子詞的按鈕。
$ truffle migrate --network testnet
1_initial_migration.js
======================
Deploying 'Migrations'
----------------------
> transaction hash: 0xaf4502198400bde2148eb4274b08d727a17080b685cd2dcd4aee13d8eb954adc
> Blocks: 3 Seconds: 9
> contract address: 0x81eCD10b61978D9160428943a0c0Fb31a5460466
> block number: 3223948
> block timestamp: 1604049862
> account: 0x623ac9f6E62A8134bBD5Dc96D9B8b29b4B60e45F
> balance: 6.24574114
> gas used: 191943 (0x2edc7)
> gas price: 20 gwei
> value sent: 0 ETH
> total cost: 0.00383886 ETH
Pausing for 5 confirmations...
------------------------------
> confirmation number: 2 (block: 3223952)
> confirmation number: 3 (block: 3223953)
> confirmation number: 4 (block: 3223954)
> confirmation number: 6 (block: 3223956)
> Saving migration to chain.
> Saving artifacts
-------------------------------------
> Total cost: 0.00383886 ETH
Summary
=======
> Total deployments: 1
> Final cost: 0.00383886 ETH
請記住您提供的地址、transaction_hash 和其他詳細信息會有所不同,以上只是提供一個結構概念。