When developing smart contracts on Testnet, use the Testnet version of the Cronos Explorer block explorer:
- Cronos Explorer Testnet URL: https://explorer.cronos.org/testnet
- Documentation of Cronos Explorer Testnet API: https://explorer-api-doc.cronos.org/testnet
$ cd cronos-smart-contract-example/truffle
$ npm install
$ cp .env.example .env
MNEMONIC=goose easy ivory ...
PRIVATE_KEY=XXXXXXX
const CronosToken = artifacts.require("CronosToken");
module.exports = function (deployer) {
deployer.deploy(CronosToken, "Cronos Token", "CRT", "1000000000000000000000000");
};
By default, the script will be using your local host "127.0.0.1"
- If you are not running a localhost, you may leverage the public endpoint https://evm-t3.cronos.org/
by making changes to networks
in truffle-config.js
, for example:
networks: {
development: {
provider: new HDWalletProvider(getHDWallet(), "http://127.0.0.1:8545"), // TODO
network_id: "*", // Any network (default: none)
},
testnet: {
provider: new HDWalletProvider(getHDWallet(), "https://evm-t3.cronos.org/"), // TODO
network_id: "*",
skipDryRun: true
},
},
npm run deploy-contract-cronos
Correct balance will be shown on Metamask page
$ cd smart-contract-example/hardhat
$ npm install
$ cp .env.example .env
MNEMONIC=goose easy ivory ...
PRIVATE_KEY=XXXXXXX
async function main() {
const CronosToken = await hre.ethers.getContractFactory("CronosToken");
const cronosToken = await CronosToken.deploy("Cronos Token", "CRT", "1000000000000000000000000");
await cronosToken.deployed();
console.log("CronosToken deployed to:", cronosToken.address);
}
By default, the script will be using your local host "127.0.0.1"
- If you are not running a localhost, you may leverage the public endpoint https://evm-t3.cronos.org/
by making changes to networks
in hardhat.config.js
, for example:
networks: {
development: {
url: "http://localhost:8545",
accounts: getHDWallet(),
},
testnet: {
url: "https://evm-t3.cronos.org/",
accounts: getHDWallet(),
},
},
npm run deploy-contract-cronos
Correct balance will be shown on Metamask page
CronosToken deployed to: 0x5F803c894a0A16B46fe5982fB5D89eb334eAF68