![](/img/trans.png)
[英]How do I use local elrond docker container node for local smart-contract development
[英]Deploying smart contract using truffle on private blockchain node on docker
我在我的私有 blockchain.network 上部署智能合约时遇到问题。 我按照此博客中的步骤在第四个虚拟机(控制器)上使用 puppeth 在三个虚拟机(矿工)上创建了我的blockchain.network:https://medium.com/@collin.cusce/using-puppeth-to-manually-创建一个以太坊权威证明-clique.network-on-aws-ae0d7c906cce
之后,我在其中一个矿工虚拟机上安装了 truffle,并使用以下命令初始化了 truffle:
truffle init
然后我写了一个简单的 hello world 智能合约,编译它并将它部署在 truffle 开发区块链上并且它工作了。 但是,我尝试将其部署在我的私有区块链上,但无法连接到 the.network。
geth 控制台中的admin.nodeInfo
命令返回以下 output:
docker exec -it 954cd3955065 geth attach ipc:/root/.ethereum/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.9.25-unstable-ead81461-20201123/linux-amd64/go1.15.5
coinbase: 0xe8cc4bea2cfdfd14cddefe1141bedd109576b9a9
at block: 78558 (Tue Dec 01 2020 22:01:02 GMT+0000 (UTC))
datadir: /root/.ethereum
modules: admin:1.0 clique:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
To exit, press ctrl-d
> admin.nodeInfo
{
enode: "enode://7206ca3c62f6db47e1230dcf14a765d4c9b4870a66470dbb21fcc5ed2fab2167d6bcc47eec8044c42037b3e6e0017aeb8ddfc3580471da54a6c7274a0c1fe46b@10.100.2.32:30303",
enr: "enr:-Je4QGXlVAESp8r2s1uHBJxoDLWQo8IvZsbe5sX2YRBb0un9Gdlt8nfDKQBR_j0lDPtaoCCuis4cJJlqtEHfa4tLO2EIg2V0aMfGhG5b-B6AgmlkgnY0gmlwhApkAiCJc2VjcDI1NmsxoQNyBso8YvbbR-EjDc8Up2XUybSHCmZHDbsh_MXtL6shZ4N0Y3CCdl-DdWRwgnZf",
id: "027a351994ac1b127df56180b6210310cc0164f17f1b12c167cb167c4ffaa122",
ip: "10.100.2.32",
listenAddr: "[::]:30303",
name: "Geth/v1.9.25-unstable-ead81461-20201123/linux-amd64/go1.15.5",
ports: {
discovery: 30303,
listener: 30303
},
protocols: {
eth: {
config: {
byzantiumBlock: 0,
chainId: 1515,
clique: {...},
constantinopleBlock: 0,
eip150Block: 0,
eip150Hash: "0x0000000000000000000000000000000000000000000000000000000000000000",
eip155Block: 0,
eip158Block: 0,
homesteadBlock: 0,
istanbulBlock: 0,
petersburgBlock: 0
},
difficulty: 98201,
genesis: "0x17f752387c901db617cf0594ecd2cb9811dfcd666318c2e0e7cb0239471da979",
head: "0xf8a37d0390558746901faa55463c127c553f02cf2d23ce0cb469fcd470c810f9",
network: 1515
}
}
}
我尝试在 truffle-config.js 中添加 .network 配置,如下所示:
devnet2: {
host: "localhost",
port: "30303", //port where the node is
network_id: "*",
from: 0x91cd7b879fefff34259d577a56d290b3315bf9b3 // Treats this network as if it was a public net. (default: false)
}
然后,当使用命令truffle deploy -.network de.net2
进行部署时,我总是会收到此错误:
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
/usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/index.js:56
throw new Error(errorMessage);
^
Error: There was a timeout while attempting to connect to the network.
Check to see that your provider is valid.
If you have a slow internet connection, try configuring a longer timeout in your Truffle config. Use the networks[networkName].networkCheckTimeout property to do this.
at Timeout.setTimeout (/usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/index.js:56:1)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
我尝试延长超时限制,但没有用。 我也尝试过使用 Web3 提供程序(HTTPProvider 和 IPCProvider),但没有任何运气(如果需要,我可以提供更多详细信息)。
非常感谢任何帮助,因为我花了很多时间在上面却一无所获。 不幸的是,我找不到任何有关将智能合约部署到运行在 docker 上的节点的信息。如果需要,我很乐意提供有关我所做工作的更多详细信息。
我在我的私有区块链网络上部署智能合约时遇到问题。 我按照以下博客中的步骤在第四个 VM(控制器)上使用 puppeth 在三个 VM(矿工)上创建了我的区块链网络: https://medium.com/@collin.cusce/using-puppeth-to-manually-create -an-ethereum-proof-of-authority-clique-network-on-aws-ae0d7c906cce
之后,我在其中一台矿工 VM 上安装了 truffle,并使用以下命令初始化了 truffle:
truffle init
然后我写了一个简单的 hello world 智能合约,编译它并将其部署在 truffle 开发区块链上,它就可以工作了。 但是,我尝试将其部署在我的私有区块链上,但无法连接到网络。
geth 控制台中的admin.nodeInfo
命令返回以下 output:
docker exec -it 954cd3955065 geth attach ipc:/root/.ethereum/geth.ipc
Welcome to the Geth JavaScript console!
instance: Geth/v1.9.25-unstable-ead81461-20201123/linux-amd64/go1.15.5
coinbase: 0xe8cc4bea2cfdfd14cddefe1141bedd109576b9a9
at block: 78558 (Tue Dec 01 2020 22:01:02 GMT+0000 (UTC))
datadir: /root/.ethereum
modules: admin:1.0 clique:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
To exit, press ctrl-d
> admin.nodeInfo
{
enode: "enode://7206ca3c62f6db47e1230dcf14a765d4c9b4870a66470dbb21fcc5ed2fab2167d6bcc47eec8044c42037b3e6e0017aeb8ddfc3580471da54a6c7274a0c1fe46b@10.100.2.32:30303",
enr: "enr:-Je4QGXlVAESp8r2s1uHBJxoDLWQo8IvZsbe5sX2YRBb0un9Gdlt8nfDKQBR_j0lDPtaoCCuis4cJJlqtEHfa4tLO2EIg2V0aMfGhG5b-B6AgmlkgnY0gmlwhApkAiCJc2VjcDI1NmsxoQNyBso8YvbbR-EjDc8Up2XUybSHCmZHDbsh_MXtL6shZ4N0Y3CCdl-DdWRwgnZf",
id: "027a351994ac1b127df56180b6210310cc0164f17f1b12c167cb167c4ffaa122",
ip: "10.100.2.32",
listenAddr: "[::]:30303",
name: "Geth/v1.9.25-unstable-ead81461-20201123/linux-amd64/go1.15.5",
ports: {
discovery: 30303,
listener: 30303
},
protocols: {
eth: {
config: {
byzantiumBlock: 0,
chainId: 1515,
clique: {...},
constantinopleBlock: 0,
eip150Block: 0,
eip150Hash: "0x0000000000000000000000000000000000000000000000000000000000000000",
eip155Block: 0,
eip158Block: 0,
homesteadBlock: 0,
istanbulBlock: 0,
petersburgBlock: 0
},
difficulty: 98201,
genesis: "0x17f752387c901db617cf0594ecd2cb9811dfcd666318c2e0e7cb0239471da979",
head: "0xf8a37d0390558746901faa55463c127c553f02cf2d23ce0cb469fcd470c810f9",
network: 1515
}
}
}
我尝试在 truffle-config.js 中添加网络配置,如下所示:
devnet2: {
host: "localhost",
port: "30303", //port where the node is
network_id: "*",
from: 0x91cd7b879fefff34259d577a56d290b3315bf9b3 // Treats this network as if it was a public net. (default: false)
}
然后,当使用命令truffle deploy --network devnet2
进行部署时,我总是会收到此错误:
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
/usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/index.js:56
throw new Error(errorMessage);
^
Error: There was a timeout while attempting to connect to the network.
Check to see that your provider is valid.
If you have a slow internet connection, try configuring a longer timeout in your Truffle config. Use the networks[networkName].networkCheckTimeout property to do this.
at Timeout.setTimeout (/usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/index.js:56:1)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
我尝试延长超时限制,但没有奏效。 我也尝试使用 Web3 提供程序(HTTPProvider 和 IPCProvider),但没有任何运气(如果需要,我可以提供更多详细信息)。
任何帮助都非常感谢,因为我花了很多时间却没有得到任何帮助。 不幸的是,我找不到任何关于将智能合约部署到在 docker 上运行的节点的信息。 如果需要,我很乐意提供有关我所做工作的更多详细信息。
我设法在 private.network 上运行智能合约,但没有使用 docker。 我想到了一些事情。 你在你的网络上运行矿工吗? 您将需要运行一个矿工,以便迁移合同。 您是否确保在运行合约时满足 gaslimit? 在处理任何请求之前,矿工将等待达到最大气体限制。 您是否已经部署了合同? 在迁移脚本中,您可以通过修改版本来创建新的迁移脚本,也可以使用重置标志再次运行所有迁移脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.