I write a simple contract , i can deploy it to ganache , but i need publish it to bnb testnet,
demo.sol:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
contract demo {
uint256 public data;
function set(uint256 _data) public {
data = _data;
}
function add() public {
data++;
}
function get() public view returns (uint256) {
return data;
}
}
hardhat.config.ts
test: {
chainId: 97,
// url:"https://bsc-testnet.public.blastapi.io",
// url:"https://bsc-testnet.publicnode.com",
url: "https://bsc-testnet-dataseed.bnbchain.org",
// url: "https://bsc-testnet.bnbchain.org",
// url: "https://bsc-testnet-rpc.publicnode.com",
accounts: ["0x ****"],
timeout: 10000,
gasPrice: 100,
},
when i use hardhat :
npx hardhat run ./scripts/deploy.ts --network test
I waited all night, and he kept showing: ,
hardhat:core:hre Creating provider for network test +4s
Can someone tell me some possible reasons
full hardhat.config.ts:
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import '@openzeppelin/hardhat-upgrades';
import "hardhat-abi-exporter";
import fs from "fs";
const privateKey = fs.readFileSync("./private.key", {
encoding: "utf-8"
});
const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.17",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: "0.6.6",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: "0.5.16",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: "0.4.18",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
}
]
},
gasReporter: {
// enabled : true,
currency: 'CNY',
gasPrice: 5,
},
networks: {
dev: {
chainId: 97,
// url:"https://bsc-testnet.public.blastapi.io",
// url:"https://bsc-testnet.publicnode.com",
url: "https://bsc-testnet-dataseed.bnbchain.org",
// url: "https://bsc-testnet.bnbchain.org",
// url: "https://bsc-testnet-rpc.publicnode.com",
accounts: ["0xf9b1d***0278e9d4674b2005911e0b2"],
timeout: 10000
},
prod:{
chainId:56,
url: 'https://rpc.ankr.com/bsc',
accounts:[privateKey],
},
local:{
chainId: 1337,
url: "http://127.0.0.1:8545",
accounts:["0x0f4108bc3a3138acac0fd7****e3e57da929"],
allowUnlimitedContractSize: true
}
},
paths: {
cache: "./runtime/cache",
artifacts: "./runtime/artifacts"
},
etherscan: {
apiKey: '****',
},
abiExporter: {
path: './runtime/abi',
runOnCompile: true,
clear: true,
flat: true,
only: [
"TPB",
"TPBGame",
"TPBMining",
"TPBWithdraw",
"demo"
]
}
};
export default config;
--network dev
if the network name is dev in hardhat config,hardhat.config.ts
file?accounts
field, likeaccounts: [privateKey]
.