- Node.js v12+ (check with: node -v)
- npm
- An Alchemy key for interacting with the Ethereum blockchain
- An Ethereum wallet private key, which will be the only wallet able to withdraw fees from the contract
- The wallet address (starting with 0x)
- To deploy the contract on Mainnet - 0.1 ETH in that wallet needed for gas
- To deploy the contract on the Rinkeby testnet - test ETH from the Chainlink faucet
git clone https://github.com/joonspoon/proxy-contract
cd proxy-contract
npm install
Create a file secrets.json
in the project root directory containing the wallet private key and Alchemy key:
{
"privateKey": "xxxxxxx",
"alchemyApiKey": "xxxx"
}
npx hardhat run --network rinkeby scripts/deploy.js
Take note of the contract address for interacting with the smart contract from now on
Check the contract has been deployed on Etherscan
Update scripts/upgrade.js
with the address of your recently deployed contract ☝️
Edit the contract code in contracts/Swap.sol
npx hardhat run --network rinkeby scripts/upgrade.js
cd Documents/proxy-contract && npx hardhat node # in a separate terminal window
npx hardhat run --network localhost scripts/deploy.js
npx hardhat run --network localhost scripts/upgrade.js
npx hardhat console --network localhost
const factory = await ethers.getContractFactory('Swap');
const contract = await factory.attach('0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0');
await contract.swap(...);
npx hardhat run --network localhost ./scripts/index.js
npx hardhat test