【发布时间】:2021-07-26 08:32:56
【问题描述】:
我目前正在学习 Solidity 并创建我的第一个项目。我正在尝试使用松露测试我的合同的部署,但我不断收到以下错误
TypeError: artifacts.reqiure is not a function
语法看起来正确并且没有出现错误。我也进入了 truffle 控制台,迁移似乎已经部署好,Color.json 现在也在我的 abis 文件夹中。
任何帮助将不胜感激,所有文件都在下面。
颜色.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);
};
【问题讨论】:
标签: javascript ethereum solidity truffle