Deploy smart contracts based on Remix+MetaMask

Due to the lack of progress in the thesis and poor grasp of the basic knowledge, Jinyou picked up the application of the blockchain again and studied some operations of the next node connection and smart contract deployment.

Basic knowledge:
remix is ​​used to deploy smart contracts, and metamask is a visual wallet.

Prepare the environment:

  1. Browser-based Remix at: http://remix.ethereum.org/ .
  2. MetaMask is a plug-in based on Chrome browser, which can be installed directly by Baidu search.

Remix:

  1. File page: Add a smart contract here, you can write it yourself or copy it.

Add smart contract

  1. Compilation page: After writing the smart contract, it needs to be compiled before deployment.

insert image description here

  1. Deployment page: Select the deployment environment on this page.

insert image description here
For details, please refer to the official website for specific instructionsinsert image description here

Click Deploy: Gas needs to be consumed during deployment. I am connected to a local private chain, and the coins can be obtained through my own miner.start().
insert image description here
insert image description here
You need to start miner.start() after deployment, otherwise it will wait forever.

MetaMask:
The first is to connect to the network. Here I am connected to the local private chain, as well as the public network and the test network.
insert image description here
This is the account, which can be created or imported by yourself:
insert image description here

This is an error I encountered when deploying the contract
insert image description here
This is the command I start the geth client:

geth --http --http.corsdomain="http://remix.ethereum.org" --http.api web3,eth,debug,personal,net --vmdebug --datadir data1 console 2>output.log --allow-insecure-unlock
末尾需要加`--allow-insecure-unlock`允许外界连接访问私链。`

Guess you like

Origin blog.csdn.net/wujian0428/article/details/129260266