deployedTo does not seem to be recognized there are no errors though. just the system fail to recognised. deployedTo is suppose to = the deployed address of my smart contract. I tired stringify, parse , cant seem to figure out what is going on. If i replace deployedTo with '00dsdsdsds22s323...' ie directly with the address string the thing work fine.
import web3 from './web3';
import InsurancePoolFactory from './build/InsurancePoolFactory.json';
require('dotenv').config();
const { deployedTo } = process.env;
const instance = new web3.eth.Contract(
JSON.parse(InsurancePoolFactory.interface),
deployedTo // the issue lies here
);
export default instance;
thanks in advance to all whom help.
The first thing to do is to test whether deployedTo
is actually read from environment, like this:
import web3 from './web3';
import InsurancePoolFactory from './build/InsurancePoolFactory.json';
require('dotenv').config();
const { deployedTo } = process.env;
console.log(deployedTo); // NEW
const instance = new web3.eth.Contract(
JSON.parse(InsurancePoolFactory.interface),
deployedTo // the issue lies here
);
export default instance;
If it is not '00dsdsdsds22s323...', but undefined
, you know your problem.
If it is indeed undefined, check the .env
file, sometimes people make silly typos there.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.