Building DeFi On Avalanche - The Hype Is Real

Goodnight, sweet prince.
Sure buddy. Heard it all before. Won’t believe it til’ I see it…
Time to grip it and rip it
Hmmm. Might just be the gamechagner we’re looking for…

The Nitty Gritty Details

The following sections are for builders. If you’re simply looking to learn more about Avalanche as an investment and economic ecosystem, check out the Ava Labs Medium page. But if you’re a coder looking to quickly get up to speed on Avalanche’s take on DeFi, come along and ride on a fantastic voyage.

  • Deploy a local Avalanche Testnet node
  • Deploy a local Avalanche wallet
  • Fund the wallet with AVAX from a faucet
  • Move that AVAX to a Metamask wallet
  • Deploy my ERC-20 token
  • Deploy Pangolin
  • Add liquidity to Pangolin with my ERC-20 token and AVAX
  • Perform a swap between AVAX and my ERC-20 token

Running A Local Avalanche Node

This is how I got this to work as of February, 2021 following the instructions on their git repo, first clone the AvalancheGo repo and build it.

go get -v -d
cd $GOPATH/src/
./build/avalanchego --network-id=local --staking-enabled=false --snow-sample-size=1 --snow-quorum-size=1
curl -X POST --data '{
"id" :1,
"method" :"info.isBootstrapped",
"params": {
}' -H 'content-type:application/json;'

Deploy a Local Avalanche Wallet and Faucet and Fund Metamask

The Avalanche wallet is where your AVAX will be held and the faucet allows you to fund the wallet with unlimited AVAX for testing. We need to pay for transaction costs, deploy smart contracts and make swaps on Pangolin. I wasn’t sure if I could fund my Metamask wallet directly with a faucet but I knew it worked when transferring from my Avalanche wallet, so the steps would look like this:

git clone
cd avalanche-wallet
yarn install
yarn serve
git clone
cd avalanche-faucet
npm install
yarn serve
Network Name: Avalanche Local
New RPC URL: http://localhost:9650/ext/bc/C/rpc
ChainID: 0xa868
Symbol: AVAX
Explorer: N/A

Creating an ERC-20 Token On Avalanche

We’ll be creating an ERC-20 token on Avalanche but instead of using Ethereum as gas, we’ll be spending AVAX as gas. Behind the scenes AVAX gets turned into WAVAX, an ERC-20 compatible wrapper contract around the AVAX token. First, load up remix using http because our node is local:
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.2;
import "";

Deploying Pangolin on Avalanche

Pangolin is a Uniswap clone. Uniswap is a decentralized cryptocurrency exchange that runs on Ethereum. It takes one cryptocurrency and converts it to another via liquidity pools and the mother of all basic price matching mechanisms. Right now as of February 2021, because Ethereum’s price is so high and the network so overburdened, fees for gas on Uniswap are very expensive, rendering Uniswap unusable for casual cryptocurrency buyers. With Avalanche’s low fees, Avalanche could solve this issue and fully unlock the theoretical potential of decentralized exchanges.

  1. Deploy factory contract.
  2. Deploy router contract.
constructor(address _feeToSetter) public { feeToSetter = _feeToSetter; }
constructor(address _factory, address _WETH) public { factory = _factory; WETH = _WETH; }
bytes32 public constant INIT_CODE_PAIR_HASH = keccak256(abi.encodePacked(type(UniswapV2Pair).creationCode));
constructor(address _factory, address _WAVAX) public {
factory = _factory;
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts);
100,["0xEA3D75C5734fdB31a463DcF5bBf10354f6077890","0x3644315edf858AB39460921e395C2dbd2b41d31f"],0x34c3a99ACcf0267965BA2Da676ab9E80F9ebF3A4, 1640995200

Let’s Gooooooooooo!

There you have it. Avalanche works. Really really well. So what is Team Prospero going to build with it?



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store