0

I am trying to deploy my smart contract. Upon deployment, I get this error message. enter image description here

Here is my contractToken.sol

pragma solidity ^0.5.2;

contract BPToken {
    uint256 public totalSupply; 

    mapping(address => uint256) public balanceOf;


    constructor(uint256 _initialSupply) public { //constructor
        totalSupply = _initialSupply;
    }
}

Here is my Token.js:

const { equal } = require("assert");

var BPToken = artifacts.require("./BPToken.sol")

    contract('BPToken', function(accounts) {
    
        var tokenInstance;

        it('sets the total supply upon deployment', function() {
        return BPToken.deployed().then(function(instance) {
            tokenInstance = instance;
            return tokenInstance.totalSupply();
        }).then(function(totalSupply) {
            assert.strictEqual(totalSupply.toNumber(), 1000000, 'sets the total supply to 1,000,000');
            return tokenInstance.balanceOf(accounts[0]);
        }); then(function(adminBalance) {
            assert.strictEqual(adminBalance, toNumber(), 1000000, "It allocates the initial supply to the admin account.")
        
        }
        
        );
    });

});

Here's my deployment:

const BPToken = artifacts.require("./BPToken.sol");

module.exports = function(deployer) {
  deployer.deploy(BPToken);
};

Would like some help in addressing what this error occurrence means, I'm new to Truffle.

2 Answers 2

0

The problem is in the migration script you need to pass the constructor parameters when deploying the contract.

In this case there's one parameter uint256 _initialSupply. So passing the initialSupply should fix the problem. For example setting it to 1000000 tokens can be done like this (due to javascript's number precision you should use strings for make it work).

module.exports = function(deployer) {
  deployer.deploy(BPToken, "1000000");
};
0

I also have a deployment error.I resolve it by deleting unnecessary smart contracts. You should try this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.