Course lesson

Deploy your Smart Contract to Goerli Test Network and App to Vercel

There are several Ethereum test networks like Ropsten, Rinkeby and Kovan that you can use to deploy your contract to have it publicly available without having to use the mainnet and real ETH. In this course you'll deploy to Rinkeby netwok (but, the process is...

Duration
6 min
Access
Included
Transcript
Retained from source evidence

There are several Ethereum test networks like Ropsten, Rinkeby and Kovan that you can use to deploy your contract to have it publicly available without having to use the mainnet and real ETH. In this course you'll deploy to Rinkeby netwok (but, the process is the same for the other networks).

The first step will be update your Metamask Wallet to connect to the Rinkeby network.

Next, you'll need some test/fake Ethere to use for testing the Dapp in the network, for that you'll need to use a faucet like this one. Just visit that faucet and add your wallet address.

You will also deploy your web application to vercel to see your project live on the internet!

🚢 Deploying to a live test network

There are several Ethereum test networks like Ropsten, Rinkeby and Kovan that you can use to deploy your contract to have it publicly available without having to use the mainnet and real ETH. In this course you'll deploy to Rinkeby netwok (but, the process is the same for the other networks).

The first step will be update your Metamask Wallet to connect to the Rinkeby network.

Next, you'll need some test/fake Ethere to use for testing the Dapp in the network, for that you'll need to use a faucet like this one. Just visit that faucet and add your wallet address.

Would be a good idea to create a new address only for testing purposes. Like the one I'm using that I called "Developer".

Enter the wallet address and click. Send Me ETH button

Then you can visit the Rinkeby Etherscan to check the status of the transaction

After the transaction is confirmed, you'll see some funds in your wallet

Setup the deploy enviroment.

To be able to deployu to the network (including testnets and mainnet) you can use a service like Infura or Alchemy.

This services will ease the process of deployment the smart contract by providing the necessary tools make the required peer-to-peer connections. This process can take hours or days to sync with all the nodes in the blockchain and can use too much bandwith. This services solves this problem by providing the infreastructure to make it quick and cost effective.

The process is similar for both services. In this course you'll use Alchemy.

Create an account with Alchemy and get your API key for the testnet.

Now you have your API KEY you need to update the hardhat configuration to add the new network.

The API URL can be grabbed from the Alchemy dashboard, then you'll need your private rinkenyu key from metamask. To get your private key (DONT SHARE IT) you can grab it from "Account Details" > "Export Private Key" The private key is required because deploying a contract is a transaction and to perform that transaction you need to "login" into the blockchain.

require('@nomiclabs/hardhat-waffle');
require('dotenv').config();

/**
 * @type import('hardhat/config').HardhatUserConfig
 */
module.exports = {
	solidity: '0.8.4',
	paths: {
		artifacts: './src/artifacts',
		sources: './src/contracts'
	},
	networks: {
		hardhat: {
			chainId: 1337 // To be able to work with metamask
		},
		rinkeby: {
			url: process.env.ALCHEMY_URL,
			accounts: [process.env.ALCHEMY_RINKEBY_ACCOUNT_KEY]
		}
	}
};

Is a good idea to save the API key into your .env file

Now your good to go. You'll only need to go to your terminal an run

Terminal
$ npm run hardhat:deploy:rinkeby

Remember: The account that you are using to deploy the contract will be the owner of the same, this account is the one that will be authorized to withdraw the funds of the contract.

Wait for the script to finish and copy the new contract address into your .env file.

Deploy the Web Client to Vercel.

Last step to be able to use your shiny new Dapp is to deploy the web client.

To do that SvelteKit use an adapter.

An adapter is an small plugin that thake the build app as input and generate the output rerquired for deployment to a particular target.

By default, all projects are configured with @sveltejs/adapter-auto, which detects the production environment and select the appropiate adapter if possible.

Currently this adapter supports Cloudflare Pages, Netlify and Vercel.

In this course you'll deploy to Vercel so, there is not further configurations required.

Create a github repository if you haven't already and a Vercel account to.

In Vercel dashboard go to "New Project" and Import the Git Repository. Vercel will immediatly pick the required configuration for it, but you need to set your environment variables first.

Go to "Environment Variables" and add the same that you have in the .env file.

After that you'll save to click "Deploy".

Wait for deploy to finish and Voila!. You have a fullstack Ethereum Dapp running!