Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
Migrate with constructor parameters in Truffle

So basically I'm not quite sure how I can get my parameters from my solidity code and pass them in the deploy function of the deployer for my 2nd migration with Truffle.

This is the constructor of my Solidity code:

constructor(
    IBEP20 _stakeToken,
    IBEP20 _rewardToken,
    uint256 _rewardPerSecond,
    uint256 _startTimestamp,
    uint256 _bonusEndTimestamp
) public {
    stakeToken = _stakeToken;
    rewardToken = _rewardToken;
    rewardPerSecond = _rewardPerSecond;
    startTimestamp = _startTimestamp;
    bonusEndTimestamp = _bonusEndTimestamp;
    // staking pool
    poolInfo.push(PoolInfo({
    lpToken: _stakeToken,
    allocPoint: 1000,
    lastRewardTimestamp: startTimestamp,
    accRewardTokenPerShare: 0
    }));
    totalAllocPoint = 1000;
}

Then this is my javascript migration code:

const tokenstaking = artifacts.require("TokenStaking");
module.exports = function(deployer) {
deployer.deploy(tokenstaking, stakeToken, rewardToken, rewardPerSecond, startTimestamp, 
bonusEndTimestamp);};

Each time I receive the same error for all parameters:

ReferenceError: stakeToken is not defined

How can I reference my parameters? help

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

for parameters you have to pass values. You defined constructor before with parameters. stakeToken, rewardToken, rewardPerSecond, startTimestamp, bonusEndTimestamp. Now you are initalizing the contract, so you have to pass arguments meaning that inital values.

So you have to get values of stakeToken, rewardToken, rewardPerSecond, startTimestamp, bonusEndTimestamp and pass it

deployer.deploy(tokenstaking, 
   "getStakeToken",  // stakeToken 
   "getRewardToken", //rewardToken, 
   "1", // 1 reward per second
   "92389424982",//startTimestamp 
    "99239323232"//bonusEndTimestamp
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!