Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 4. 🔮 The deployment!.md #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,88 +1,61 @@
# 🎉 Writing smart contract
🎉 Writing smart contract
=========================

## **🔮 The deployment!**
##### 🔮 The deployment!

Go to the scripts folder and create a new file called deploy.js

Copy the following boiler plate code into your file.

```js
async function main() {
const Collection = await ethers.getContractFactory("Collection")
const collection = await Collection.deploy()
await collection.deployed()
console.log("Contract deployed to address:", collection.address)
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})
```
`async function main() { const Collection = await ethers.getContractFactory("Collection") const collection = await Collection.deploy() await collection.deployed() console.log("Contract deployed to address:", collection.address) } main() .then(() => process.exit(0)) .catch((error) => { console.error(error) process.exit(1) })`

This is standard code that you would find in any ethers.js or hardhat documentation.

You first create a contract factory called Collection.

```js
const Collection = await ethers.getContractFactory("Collection")
```
`const Collection = await ethers.getContractFactory("Collection")`

You can now use this contract factory to deploy as many contract as you want.

But we only need to deploy one. (Goerli test eth is free, but why waste it 😝)

```js
await collection.deployed()
console.log("Contract deployed to address:", collection.address)
```
`await collection.deployed()`

`console.log("Contract deployed to address:", collection.address)`

From this one deployed smart contract we can mint as many NFTs as our heart pleases.

The smart contract is ready.
The hardhat config is ready.
The deploy script is ready.
The smart contract is ready. 
The hardhat config is ready. 
The deploy script is ready. 
Are you readdyyyyyyyy? 🚀🚀🚀🚀🔥🔥🔥

If yes, then just type this command into your command line, to deploy your contract on the goerli network.

```bash
npx hardhat run scripts/deploy.js --network goerli
```
`npx hardhat run scripts/deploy.js --network goerli`

Don’t panic if you don’t see anything for some time on your command line. You are now interacting with an ethereum network, so transactions might take some time.

You can use this time to go the alchemy mempool from your dashboard and view your transaction.

On a successful transaction confirmation you should see something like this.

```
Contract deployed to address: <your_contract_address>
```
`Contract deployed to address: <your_contract_address>`

Congratulations you have just deployed your own smart contract to the ethereum test network!

Store this contract address somewhere. We will need it later.

At this point I would recommend taking a step back and appreciating what you have done here. 👏👏👏👏👏

Go to the [goerli etherscan](https://goerli.etherscan.io/) and paste in your contract address. View your transaction details here, click on your transaction hash to understand the elements that were involved in your transaction.
Go to the [goerli etherscan](https://goerli.etherscan.io/) and paste in your contract address. View your transaction details here, click on your transaction hash to understand the elements that were involved in your transaction.

You will probably be using etherscan a lot in the future, so it would be helpful to get yourself familiar with it :)

## Summary
Summary
-------

You are now a very smart, smart contract developer.
You are now a very smart, smart contract developer. 
But I promised you I would give you an NFT Marketplace by the end of this tutorial, and I intend to keep that promise.

So let’s move on to building a quick react frontend for our marketplace and then calling our deployed smart contract to mint for us, some awesome NFTs.

### Assignment

#### 🚨 Progress Report

Share your deployed smart contract address

**Your response is**