truffle - artifacts.require 不是函数
truffle - artifacts.require is not a function
我目前正在学习 solidity 并创建我的第一个项目。我正在尝试使用 truffle 测试我的合同部署,但我不断收到以下错误
TypeError: artifacts.reqiure is not a function
语法看起来正确,没有出现错误。我也进入了 truffle 控制台,迁移似乎已经部署正常,Color.json 现在也在我的 abis 文件夹中。
任何帮助将不胜感激,所有文件都在下面。
Color.sol
pragma solidity 0.5.0;
import "./ERC721Full.sol";
contract Color is ERC721Full {
// Initialise function
constructor () ERC721Full("Color", "COLOR") public {
}
}
Color.test.js
const Color = artifacts.reqiure('./Color.sol')
require('chai')
.use(require('chai-as-promised'))
.should()
contract('Color', (accounts) => {
let contract
before(async () => {
contract = await Color.deployed()
})
describe('deployment,', async() => {
it('deploys successfully', async() => {
contract = await Color.deployed()
const address = contract.address
console.log(address)
assert.notEqual(address,"")
assert.notEqual(address, 0x0)
assert.notEqual(address, null)
assert.notEqual(address, undefined)
})
it('has a name', async () => {
const name = await contract.name()
assert.equal(name, 'Color')
})
it('has a symbol', async () => {
const symbol = await contract.symbol()
assert.equal(symbol, 'COLOR')
})
})
})
2_deploy_contracts.js
const Color = artifacts.require("Color");
module.exports = function(deployer) {
deployer.deploy(Color);
};
1_init_migration.js
const Migrations = artifacts.require("Migrations");
module.exports = function(deployer) {
deployer.deploy(Migrations);
};
您输入有误 Color.test.js
const Color = artifacts.reqiure('./Color.sol')
应该是require
我尝试了这个特定的代码,它显示了一条错误消息,在查看该行后,它只是颜色代码中这一特定行的一个小拼写错误:-
const Color = artifacts.reqiure('./Color.sol')
尝试将其替换为:-
const Color = artifacts.require('./Color.sol')
确保你有
require('@nomiclabs/hardhat-truffle5');
在您尝试致电 artifacts.require
之前
我目前正在学习 solidity 并创建我的第一个项目。我正在尝试使用 truffle 测试我的合同部署,但我不断收到以下错误
TypeError: artifacts.reqiure is not a function
语法看起来正确,没有出现错误。我也进入了 truffle 控制台,迁移似乎已经部署正常,Color.json 现在也在我的 abis 文件夹中。
任何帮助将不胜感激,所有文件都在下面。
Color.sol
pragma solidity 0.5.0;
import "./ERC721Full.sol";
contract Color is ERC721Full {
// Initialise function
constructor () ERC721Full("Color", "COLOR") public {
}
}
Color.test.js
const Color = artifacts.reqiure('./Color.sol')
require('chai')
.use(require('chai-as-promised'))
.should()
contract('Color', (accounts) => {
let contract
before(async () => {
contract = await Color.deployed()
})
describe('deployment,', async() => {
it('deploys successfully', async() => {
contract = await Color.deployed()
const address = contract.address
console.log(address)
assert.notEqual(address,"")
assert.notEqual(address, 0x0)
assert.notEqual(address, null)
assert.notEqual(address, undefined)
})
it('has a name', async () => {
const name = await contract.name()
assert.equal(name, 'Color')
})
it('has a symbol', async () => {
const symbol = await contract.symbol()
assert.equal(symbol, 'COLOR')
})
})
})
2_deploy_contracts.js
const Color = artifacts.require("Color");
module.exports = function(deployer) {
deployer.deploy(Color);
};
1_init_migration.js
const Migrations = artifacts.require("Migrations");
module.exports = function(deployer) {
deployer.deploy(Migrations);
};
您输入有误 Color.test.js
const Color = artifacts.reqiure('./Color.sol')
应该是require
我尝试了这个特定的代码,它显示了一条错误消息,在查看该行后,它只是颜色代码中这一特定行的一个小拼写错误:-
const Color = artifacts.reqiure('./Color.sol')
尝试将其替换为:-
const Color = artifacts.require('./Color.sol')
确保你有
require('@nomiclabs/hardhat-truffle5');
在您尝试致电 artifacts.require