我实际上正在使用松露和 Ganache 进行一些开发。
我想知道 Ganache 在哪里存储它的区块链以查看我的测试使用了多少数据。它是否存储在 PC 上可访问的某个地方?
我正在使用
我正在使用松露部署合同,当我指定气体限制作为我想用于交易的气体时,我总是得到超过气体限制的错误.为什么会这样?
编辑我要做的是将crypto kitties KittyCore.sol合同部署到我的本地devnet.我正在使用松露来部署它.
从另一个页面,如何在使用继承时将松露合同部署到开发网络?,我发现由于存在合同层次结构,我需要按顺序部署合同.我使用了这种技术,并且我能够部署7个合同中的4个,第五个,KittyAuction,给出以下错误:合同代码无法存储,请检查您的燃气量
下面发布的是我的松露部署脚本
var KittyCore = artifacts.require("KittyCore");
var KittyMinting = artifacts.require("KittyMinting");
var KittyAuction = artifacts.require("KittyAuction");
var KittyBreeding = artifacts.require("KittyBreeding");
var KittyOwnership = artifacts.require("KittyOwnership");
var KittyBase = artifacts.require("KittyBase");
var KittyAccessControl = artifacts.require("KittyAccessControl");
var SaleClockAuction = artifacts.require("SaleClockAuction");
module.exports = function (deployer) {
deployer.deploy(KittyAccessControl).then(function () {
return deployer.deploy(KittyBase).then(function () {
return deployer.deploy(KittyOwnership).then(function () {
return deployer.deploy(KittyBreeding).then(function () {
return deployer.deploy(KittyAuction, {
gas: 400000
}).then(function () {
return deployer.deploy(KittyMinting).then(function () {
return deployer.deploy(KittyCore);
})
})
})
})
})
}); …Run Code Online (Sandbox Code Playgroud) 无法更正尝试安装松露的 EACCESS 问题。
是的,我最初是通过 sudo 而不是 nvm 安装了 npm,但这已得到纠正 - 除非谁知道 - 根据网络。
这条路径实际上并不存在,所以我根据一个 git 问题创建了它:
/root/.config/truffle/
[root@home config]# ls -la |grep truffle
drwxrwxr-x. 2 root root 6 Jul 14 17:08 truffle
[user@home ~]$ nvm --version
0.34.0
$ npm -v
6.9.0
Run Code Online (Sandbox Code Playgroud)
分配完全权限node_modules:
ll|grep node
drwxrwxrwx. 31 user user 4096 Jul 14 16:58 node_modules
Run Code Online (Sandbox Code Playgroud)
我尝试了此链接中的建议:安装 npm 模块时权限被拒绝。
Ethereum SE 的用户在 Ubuntu问题上有这个问题。
浏览以下链接并授予 package-lock 的完全权限,以防问题npm 通知创建了一个锁文件为 package-lock.json。你应该提交这个文件
尝试强制清除 npm 缓存。
这个 github 用户显然通过 …
我已经命令npm run dev运行我的代码。但是,它弹出了几个错误它弹出的第一个错误是Module not found: Error: Can't resolve '../../build/contracts/User.json'我不知道为什么会弹出这个错误,因为在我的webpack.config.js文件中我已经设置了
loaders: [
{ test: /\.json$/, use: 'json-loader' },
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['es2015'],
plugins: ['transform-runtime']
}
}
]
Run Code Online (Sandbox Code Playgroud)
我试过把json-loader改成json,还是不行。 https://github.com/webpack-contrib/json-loader/issues/17
webpack.config.js
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: './app/javascripts/app.js',
output: {
path: path.resolve(__dirname, 'build'),
filename: 'app.js'
},
plugins: [
// Copy our app's index.html to the build folder.
new CopyWebpackPlugin([
{ from: './app/index.html', to: …Run Code Online (Sandbox Code Playgroud) 我想使用 npm 安装 ganache-cli 和 truffle,但遇到两种类型的错误(请参阅下面粘贴的代码)。
如果我运行命令 npm config,我会收到以下错误。这可能是2中错误的原因吗?
:~ 约翰$ npm 配置 npm 错误!用法: npm 错误!npm 配置集 npm 错误!npm 配置获取 [] npm 错误!npm 配置删除 npm 错误!npm 配置列表 [--json] npm 错误!npm 配置编辑 npm 错误!npm 设置 npm 错误!npm 获取 [] npm 错误! npm 错误!别名:
当我安装该ganache-cli模块时,出现以下错误:
约翰$ npm uninstall -g ganache-cli && npm install -g ganache-cli 0.036 秒内更新 /Users/john/.npm-global/bin/ganache-cli -> /Users/john/.npm-global/lib/node_modules/ganache-cli/cli.jskeccak@1.4.0 安装/Users/john/.npm-global/lib/node_modules/ganache-cli/node_modules/keccak npm 运行重建 || echo "Keccak 绑定编译失败。将使用纯 JS 实现。"
keccak@1.4.0 重建 /Users/john/.npm-global/lib/node_modules/ganache-cli/node_modules/keccak …
我正在尝试使用 truffle 将合约部署到 ropsten 测试网,但出现以下错误:
Deploying 'Migrations'
----------------------
Error: *** Deployment Failed ***
"Migrations" -- invalid sender.
at /home/usr/.npm/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.2.5 (core: 5.2.5)
Node v10.19.0
Run Code Online (Sandbox Code Playgroud)
在本地部署到 ganache 时,它工作正常。此外,我很确定我的 truffle-config.js 是正确的,它与所有在线教程相同,但既然我在这里,我想我并不完全确定 :)。hd-wallet 使用的地址也是正确的(通过 truffle-config.js 中的 console.log 语句验证),并且它有 5 个 ETH 余额,足够了。我有 2 个迁移脚本,每个脚本都给出了完全相同的错误。
松露-config.js:
Deploying 'Migrations'
----------------------
Error: *** Deployment Failed ***
"Migrations" -- invalid sender.
at /home/usr/.npm/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.2.5 (core: 5.2.5)
Node v10.19.0
Run Code Online (Sandbox Code Playgroud)
1_initial_migration.js:
require("dotenv").config();
const HDWalletProvider = require("@truffle/hdwallet-provider");
module.exports = {
networks: { …Run Code Online (Sandbox Code Playgroud) 我正在开发一个简单的以太坊合约,它是松露测试的对应部分,但我遇到的问题是我需要测试来调用合约的旧部署,而不是每次都重新部署它。
在truffle文档中,它说当要重新部署合约时应使用contract()函数,而在所有其他情况下应使用mocha的describe()函数,但即使使用describe,geth客户端也会报告每次重新部署合约。
这是测试:
var md5 = require('md5');
var AuditRecord = artifacts.require("AuditRecord");
describe('AuditRecord', function() {
before(function() {
audit = AuditRecord.at('0x30ad3ceaf3f04696d1f7c8c4fbb9cfe4f7041822');
for (var i = 0; i < 10; ++i) {
if (Math.random() < 0.3) {
audit.enter(i, i, md5("test"), md5("data"), Date.now().toFixed());
} else {
audit.enter(i, i, md5("special_case"), md5("data"), Date.now().toFixed());
}
}
return audit.LogRecord({}, { fromBlock: 0, toBlock: 'latest'});
});
it("should read data", function() {
auditLog = AuditRecord.at('0x30ad3ceaf3f04696d1f7c8c4fbb9cfe4f7041822').LogRecord({}, { fromBlock: 0, toBlock: 'latest'});
auditLog.get(function(err, data) {
console.log("\n\n\n\t.:::: testing lookup:\n")
if (err) {
console.log(err); …Run Code Online (Sandbox Code Playgroud) windows 10 Home x64
bignumber.js@^7.2.1
openzeppelin-solidity@1.10.0
React@16.4.1
React-dom@16.4.1
truffle@4.1.13
web3@1.0.0-beta.34
完整版本参考:
https ://github.com/tooploox/ethereum-ico-examples/blob/master/package.json
我做了很多研究。我找到了很多来源,但没有一个找到解决方案,并且某些线程不再更新,或者可能他们已经找到答案但没有发布。有些人设法在 Mac 中修复它,但我使用的是 Windows。5个月前有人修好了,但当我尝试时,它没有成功,买来把油调高一点,然后再次运行。6 Ether我的 Ropsten 帐户中也有。
这是我的truffle.js:
ropsten: {
provider: new HDWalletProvider(mnemonic, "https://ropsten.infura.io/"+infura_apikey),
network_id: 3,
gas: 4000000
},
Run Code Online (Sandbox Code Playgroud)
当我truffle migrate --network ropsten:
it triggers this error:
Running migration: 1_initial-migration.js
Deploying Migrations...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
insufficient funds for gas * price + value
Run Code Online (Sandbox Code Playgroud)
Github 参考:
https://github.com/tooploox/ethereum-ico-examples
指令参考:
https://www.tooploox.com/blog/create-and-distribute-your-erc20-token-with-openzeppelin
我正在尝试通过优化代码来节省汽油。然而,我突然想知道在 Solidity 中从一个数组复制到另一个数组的最佳实践是什么。
我提出两个选择。一种是通过指针复制(我猜),另一种是使用 for 循环。
TestOne.sol
contract TestContract {
uint32[4] testArray;
constructor(uint32[4] memory seeds) {
testArray = seeds; // execution costs: 152253
}
function Show() public returns (uint32[4] memory) {
return testArray;
}
}
Run Code Online (Sandbox Code Playgroud)
测试二.sol
contract TestContract {
uint32[4] testArray;
constructor(uint32[4] memory seeds) {
for(uint i = 0; i < 4; i++) {
testArray[i] = seeds[i]; // execution costs: 150792
}
}
function Show() public returns (uint32[4] memory) {
return testArray;
}
}
Run Code Online (Sandbox Code Playgroud)
我使用 Remix(以太坊在线 IDE)、0.8.13 Solidity 编译器和启用优化进行了测试(200)