Contract Deployment

How To Deploy A Token Using Vyper on Goerli Testnet

written by
Chris Cao
Date Last Updated
August 16, 2022
Download Project Files

In this tutorial, Chris demonstrates how to deploy a simple ERC-20 token on the Goerli testnet using Vyper with Ape Framework. You will need to install Ape and connect to the Goerli Testnet with tokens to pay gas fees for the transaction.

PREREQUISITES to Understanding this Tutorial

You should understand before deploying smart contracts:

Deploying a contract also costs ether (ETH), so you should be familiar with gas and fees on Ethereum and You can learn how to make an Account or Wallet.

How to deploy a Smart Contract

Congrats! If you are reading this, you probably downloaded Ape framework, learned about the unique console features and maybe even played around with the framework's modular plugins. Now it's time to deploy a contract using Ape! This is one of the important ways data gets stored and organized on the Ethereum blockchain.

Deploying a smart contract is a unique type of transaction where we don’t necessarily care about the receipt as much as we care about the contract instance. That is why the return value from the deploy method is a ContractInstance.

Requirements for deploying your contract to a network:

For this tutorial, I installed (3) second-party plugins that are maintained by our core developers to make it as easy as possible. 

ens to pass in decentralized naming for wallets and websites for parameters in arguments.

etherscan to explore Ethereum-based networks.

Alchemy to connect to a remote ETH Node so I can capture and log all actions on the contract to a place that is tangible.

Ape Tip: This is one of the many ways to connect to a network and deploy a contract.

Step 0: Creating/ Importing an account to deploy a contract

Deploying a contract requires eth. So please follow the tutorial on how to get an account with ape or import an account. 

Link to Account Tutorial Here

Step 1: Deploy the Contract

Deploying from ape console allows you to interact with a contract in real time. Ape Academy also provides an article tutorial on navigating ape_console. 

You can also use the --network flag to connect a live network.

Once you launch console it will change the CLI to IPython

This will launch an IPython Interactive shell:

$ ape console --network ethereum:goerli:alchemy

Once you launch ape console with a network. Lets deploy a contract!

$ In [1]: dev = accounts.load("dev")
$ In [1]: contract = dev.deploy(project.Token)
$ In [1]: contract = accounts.transfer("rec_address", amount, sender=dev)

In [1]: dev = accounts.load("dev")

This loads the account your created or imported in the Ape Console.

In [2]: contract = dev.deploy(project.Token)

This deploys the contract and saves it to the token variable.

In [3]: contract.[TAB][TAB][TAB]

With the token variable you have access to all the methods you implemented in your contract.

Step 4: Send tokens to an address (OPTIONAL)

The contract is deployed! You can view it on etherscan.

Now you can send tokens to any valid address.

Hot Tip: Redeploy a contract

If you want to exit and relaunch your contract. You do not have to redeploy the contract. You can just access the contract at the address.

$ In [1]: contract ="contract_address")

Script Deploy Contracts

You can write scripts that run using the ape run command. The ape run command will register and run Python files defined under the scripts/ directory that do not start with an _ underscore. The scripts folder is part of ape directory structure, you can learn more about it here.

Technical Documentation for Script Deploy Contracts

CLI Scripts:

A cool thing about ape is that we utilize click commands to run our Command Line Interface(CLI). Which means you can create python scripts to deploy contracts in terminal. One of the perks about running a cli script is that you can specify which network to run in here.

#perk you can add args unlike main method
@click.option("--uri", help = "base uri for nft", default = "dummy value")
# cli_ctx must go first
def cli(cli_ctx, network, uri):
    Deploy the nft
    network =
    if network == LOCAL_NETWORK_NAME or network.endwith("-fork"):
        account = cli_ctx.account_manager.test_accounts[0]
        account = get_user_selected_account()

Main Method:

This is the quickest and simplest way to deploy a contract. You can read more about it in the tech doc.

def main():
    account = get_user_selected_account()


Deploying a smart contract is relatively straightforward, but a few transaction details should be considered on a testnet before you can launch live to the mainnet. Blockchain platforms, like Ethereum, operate on-chain and require you to take specific steps to ensure that you are deploying your smart contract correctly.

If you have questions about this tutorial, come say gm on our Discord and connect with our global community of Pythonistas. Come say gm on Discord!