Hello,
I am very new to smart contract development and I am facing a problem when testing with Truffle.
Below is the code to reproduce the problem, and the error message: "intrinsic gas too low".
I guess that gas is lacking somewhere, but it is not very clear for me if (and how!) something has to be changed in the truffle-config.js, in the migration script or if ether should be added to the truffle test wallets.
Thank you in advance for your help.
Code to reproduce
// contracts/MyToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC777/ERC777.sol";
contract MyTokenContract is ERC777 {
constructor(uint256 initialSupply, address[] memory defaultOperators)
ERC777("MyToken", "MTK", defaultOperators)
{
_mint(msg.sender, initialSupply, "", "");
}
}
// 2_deploy_mytoken.js
const MyTokenContract = artifacts.require("MyTokenContract");
const initialSupply = 10000;
const defaultOperators = [];
module.exports = async function(deployer, network, accounts) {
deployer.deploy(MyTokenContract, initialSupply, defaultOperators);
};
// truffle-config.js
const path = require("path");
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
contracts_build_directory: path.join(__dirname, "client/src/contracts"),
networks: {
develop: {
host: "127.0.0.1",
port: 7545,
network_id: "*",
}
},
compilers: {
solc: {
version: "^0.8.0"
}
}
};
Error message:
% truffle test
Using network 'test'.
Compiling your contracts...
===========================
> Compiling ./contracts/@ETHTokent.sol
> Artifacts written to /var/folders/5b/8tkq7qs17k734h1j8jft220w0000gn/T/test--2167-HIN38nLdUWFD
> Compiled successfully using:
- solc: 0.8.11+commit.d7f03943.Emscripten.clang
Error: while migrating MyTokenContract: Returned error: intrinsic gas too low
at /opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Migration._deploy (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:70:1)
at Migration._load (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:56:1)
at Migration.run (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:217:1)
at Object.runMigrations (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
at Object.runFrom (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
at Object.runAll (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:114:1)
at Object.run (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:79:1)
at Object.run (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/core/lib/testing/Test.js:114:1)
at Object.module.exports [as run] (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/test/run.js:102:1)
at Command.run (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:189:1)
Truffle v5.4.31 (core: 5.4.31)
Node v17.4.0
Environment
Truffle v5.4.31 (core: 5.4.31)