Aurora is an EVM-based network that benefits from the security and scalability of NEAR. Technically, Aurora is a shard of NEAR that supports Solidity. There's nothing as simple as deploying an ERC-20 token on Aurora Testnet.
Aurora Testnet setup
Go to https://aurora.dev/start, in the Aurora Network
section, select the testnet
tab and click on Add Network
: this will add Aurora Testnet as a new network in your MetaMask wallet.
Head to Aurora Testnet faucet and click on the testnet
button. Now you can just click on the Connect to Aurora Testnet
button, it will turn into a Request 0.001 ETH from faucet
button: just click it to get 0.001 ETH. That will be more than enough to deploy your ERC-20 token contract.
If you need more, you can use the Testnet Rainbow Bridge to transfer some Goerli ETH to Aurora Testnet.
Hardhat config
- Clone this repository: https://github.com/julienbrg/dune-erc20
- Copy the
.env.example
file - Rename it
.env
- In MetaMask, export the private key of the wallet holding the Aurora Testnet ETH, copy-paste it after the equal sign (line 3)
- In your terminal (in your root directory):
npm i
The ERC-20 contract
This is a very basic ERC-20 token that's using open Zeppelin Solidity contracts library. There's only one function: the mint()
function. The visibility is set to public, meaning that anyone can call this function and mint as many units as he/she wants (we're in an 'open bar' mode, so to speak):
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract Dune is ERC20 {
constructor() ERC20("Dune", "DUNE") {}
function mint(address to, uint256 amount) public {
_mint(to, amount);
}
}
You can test this contract with:
npx hardhat test
Then just deploy it to Aurora Testnet:
npx hardhat run scripts/deploy.ts --network aurora_testnet
You should get something like this:
ERC-20 deployed at 0x51723295B6E50d94D887Bbc70c1AE0ab1Fa3a469 ✅
On Aurorascan, your deployment transaction will look like this:
Congrats, you just deployed a Solidity contract to Aurora Testnet! 🎉
To mint and transfer a handful of DUNE to yourself (or to a friend of yours), you can use this command:
npx hardhat run scripts/transfer.ts --network aurora_testnet
For info, there's even a frontend available if you want to mint some Dune tokens: https://dune-aurora.netlify.app/. It was made using React, Web3Auth and a builder called Plasmic. The Github repo is here (there's a dune
branch) if you want to have a look.
Now let's deploy to Mainnet...
Deploy to Aurora Mainnet
We're going to use a tool called Aurora+. Please head to https://aurora.plus, and sign up to get your 50 free tx per months. Once you've done that, you have your personalized RPC endpoint URL that is waiting for you (top-right menu):
You can copy-paste that URL into your .env
file (line 1).
Then you want to export your wallet's private key into your .env
file as well.
Something is missing in that .env
file and it's the Aurorascan API key. You're going to need it to make it easy for everyone to read the source code of your contract, you can use Aurorascan API:
https://aurorascan.dev/myapikey
You can sign up there, click on API-key in the left menu, then click on add
to create an API key. Copy-paste it in the .env
file.
In the deploy.ts
file uncomment the lines 15, 16 and 17, and:
npx hardhat run scripts/deploy.ts --network aurora_mainnet
Congrats! 🎉
Your ERC-20 is deployed to Aurora Mainnet, you paid nothing, the source code is available for everyone to verify what's going on, and people can even trigger the mint function directly from Aurorascan.
And you can also use the transfer.ts
script to mint some DUNE:
npx hardhat run scripts/transfer.ts --network aurora_mainnet
Thanks for your read!
Photo by Henrik Heitmann
Feel free to contact me via Element, Telegram, Twitter, Discord, or LinkedIn.
Top comments (0)