javascript - 合约部署后 Ganache 不更新账户余额
问题描述
我与 Ganache 和 nodeJS 一起工作。每当我努力使用 JavaScript 部署我的合约时,都会挖掘相关块,这表明给定的合约已部署,但发送者帐户(或部署者帐户)的余额不会更新。我可以看到有什么问题。
JavaScript 代码:
const Web3 = require("web3");
web3 = new Web3(new Web3.providers.HttpProvider(Web3.currentProvider));
.
.
.
const cid = <a value>;
const pid = <a value>;
const source2='path of my solidity file';
const compiledMyContract = solc.compile(source2);
const myContractJson="path of json version of my solidity file";
const myContractJs = JSON.parse(fs.readFileSync(myContractJson));
const contractByteCode="...";
const gasEstimate = await web3.eth.estimateGas({data: contractByteCode});
const myContract = new web3.eth.Contract(myContractJs.abi, null, {data: contractByteCode});
myContract.deploy().send({from:<address>, gas: gasEstimate, gasPrice:
200}).then((instance) => {
console.log("Contract mined at " + instance.options.address);
instance.methods.function_A(cid, pid).send({
from:<address>,
gas: 2000000,
gasPrice: 200
});
.
.
.
解决方案
推荐阅读
- php - 当 SQL 字符串具有“%f”时,Wordpress wpdp->getResults 不执行我的 sql
- ios - 将 Flutter 集成到 CocoaTouch SDK 中?
- system-verilog - 将 8 位值传递给 1 位端口?
- protocol-buffers - 如何将 OpenAPI Spec (Swagger 2.0) 转换为 proto3?
- python - 从坐标列表中分配所有可能的顶点组合并对其进行缩放
- c# - 即使在使用事务时,C# SQLite Bulk 参数化 DELETE 也会很慢?
- php - 在 Woocommerce 商店循环中添加限制为可用数量的产品数量字段
- angular - 在 Kubernetes 中运行 npm 应用程序
- android - 完成应用卸载后,Android 会“记住”共享偏好
- android - 使用 edujugon 推送通知的 Laravel Web 推送通知