Alchemy is a remote version of an Ethereum Node. Sign up and create an app. https://www.alchemy.com/
Switch your metamask to ropsten network and get some ETH from the faucet.
- https://ipfs.io/ipfs/QmVAwVKys271P5EQyEfVSxm7BJDKWt42A2gHvNmxLjZMps/
- https://faucet.dimensions.network/
- https://faucet.metamask.io/
- https://faucet.ropsten.be/
- https://faucet.bitfwd.xyz/
$ npm init -y
$ npm i dotenv --save
Add a .env
file
METAMASK_PRIVATE_KEY = "yourMetamaskPrivateKey"
API_URL = "https://eth-ropsten.alchemyapi.io/v2/your-api-key"
Get your metamask private key by opening up the MetaMask extension, click the three dots in the top right, and select the Account Details option. Next, click the Export Private Key button. Enter your password to see your private key, then copy it.
Get your alchemy key by going to your app (that you just created above).
Hardhat let's you test smart contracts locally without deploying. Alternatives are truffle, brownie, embark, etherlime.
$ npm install --save-dev hardhat && npx hardhat
> Create a sample project
Edit hardhat.config.js
// Load the .env to memory
require('dotenv').config();
require("@nomiclabs/hardhat-ethers");
// Itemize out the .env variables
const { API_URL, METAMASK_PRIVATE_KEY } = process.env;
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
defaultNetwork: "ropsten",
networks: {
hardhat: {},
ropsten: {
url: API_URL,
accounts: [`0x${METAMASK_PRIVATE_KEY}`]
}
},
solidity: {
version: "0.8.4",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts"
},
mocha: {
timeout: 20000
}
};
$ npx hardhat run scripts/sample-script.js --network ropsten
Compiling 2 files with 0.7.3
Compilation finished successfully
Greeter deployed to: 0x1234567890