I'm having an issue deploying a contract with Truffle. The contract constructor takes 7 parameters which are all within the 2_deploy_xxx.js
file. However, every time I do, I get an error when I get to deploying the actual contract. The contract takes an oracle (AggregatorV3Interface from ChainLink). I'm stumped and wondered if anyone would be able to help me as I've stared at this for too long.
truffle-config.js
const HDWalletProvider = require('truffle-hdwallet-provider');
require('dotenv').config();
const BSC_DEPLOYER_KEY = process.env.BSC_DEPLOYER_KEY;
const BSC_TESTNET_DEPLOYER_KEY = process.env.BSC_TESTNET_DEPLOYER_KEY;
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*",
},
testnet: {
provider: () => new HDWalletProvider(BSC_TESTNET_DEPLOYER_KEY, `https://data-seed-prebsc-1-s1.binance.org:8545`, 0, 10),
network_id: 97,
confirmations: 10,
timeoutBlocks: 200,
skipDryRun: true,
from: 'address',
},
bsc: {
provider: () => new HDWalletProvider(BSC_DEPLOYER_KEY, `https://bsc-dataseed1.binance.org`),
network_id: 56,
confirmations: 10,
timeoutBlocks: 200,
skipDryRun: true,
},
},
plugins: [
'truffle-plugin-verify'
],
api_keys: {
etherscan: process.env.BSCSCAN_API_KEY
},
mocha: {
// timeout: 100000
},
compilers: {
solc: {
version: "0.6.12",
settings: {
optimizer: {
enabled: true,
runs: 999999
},
}
},
}
}
2_deploy_prediction.js
const BnbPricePrediction = artifacts.require("BnbPricePrediction");
const AggregatorV3Interface = artifacts.require("AggregatorV3Interface");
const ADMIN_ADDRESS = '';
const OPERATOR_ADDRESS = '';
const INTERVAL_BLOCKS = 100;
const BUFFER_BLOCKS = 20;
const MIN_BET_AMOUNT = 1000000000000000;
const ORACLE_UPDATE_ALLOWANCE = 300;
module.exports = function (deployer, network, accounts) {
console.log(network);
let adminAddress = ADMIN_ADDRESS;
let operatorAddress = OPERATOR_ADDRESS;
let intervalBlocks = INTERVAL_BLOCKS;
let bufferBlocks = BUFFER_BLOCKS;
let minBetAmount = MIN_BET_AMOUNT;
let oracleUpdateAllowance = ORACLE_UPDATE_ALLOWANCE;
deployer.deploy(AggregatorV3Interface);
let oracle = AggregatorV3Interface.address
deployer.deploy(
BnbPricePrediction,
oracle,
adminAddress,
operatorAddress,
intervalBlocks,
bufferBlocks,
minBetAmount,
oracleUpdateAllowance
);
console.table({
BnbPricePrediction:BnbPricePrediction.address
})
};
Truffle Error
2_deploy_prediction.js
======================
testnet
Error: BnbPricePrediction has no network configuration for its current network id (97).
at Function.network (/Users/n0rden/.config/yarn/global/node_modules/truffle/build/webpack:/packages/contract/lib/contract/properties.js:108:1)
at Function.getter (/Users/n0rden/.config/yarn/global/node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:282:1)
at Function.get (/Users/n0rden/.config/yarn/global/node_modules/truffle/build/webpack:/packages/contract/lib/contract/properties.js:129:1)
at Function.getter (/Users/n0rden/.config/yarn/global/node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:279:1)
at module.exports (/Users/n0rden/tendie-prediction/migrations/2_deploy_prediction.js:36:47)
at Migration._load (/Users/n0rden/.config/yarn/global/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:56:1)
at Migration.run (/Users/n0rden/.config/yarn/global/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:203:1)
at Object.runMigrations (/Users/n0rden/.config/yarn/global/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
at Object.runFrom (/Users/n0rden/.config/yarn/global/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
at Object.runAll (/Users/n0rden/.config/yarn/global/node_modules/truffle/build/webpack:/packages/migrate/index.js:114:1)
at Object.run (/Users/n0rden/.config/yarn/global/node_modules/truffle/build/webpack:/packages/migrate/index.js:79:1)
at runMigrations (/Users/n0rden/.config/yarn/global/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:263:1)
at Object.run (/Users/n0rden/.config/yarn/global/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:228:1)
at Command.run (/Users/n0rden/.config/yarn/global/node_modules/truffle/build/webpack:/packages/core/lib/command.js:136:1)
deployer.deploy
is async and you aren'tawait
ing for it.