Shang Silicon Valley Ethereum blockchain learning (1)

Difficult to name 2022-04-06 04:08:37 阅读数:736

shang silicon valley ethereum blockchain


Preface

Tips : Service outsourcing blockchain learning
Record operation
Direct link of Silicon Valley Ethereum blockchain

One 、MataMask

Chrome Add extensions to the browser MataMask
Chrome The online app store can't open , Ladder needed , And fox and Edge There is no need to
Anyway, learning this requires a ladder
Ethereum official website
 Insert picture description here
If it is a test network, add the test network name in front of it , for example :ropsten.etherscan.io

Two 、Remix Use (Solidity)

Remix Official website

1. Create a virtual faucet contract

contracts->New File
File naming :Faucet.sol
 Insert picture description here

2. Write a contract

The faucet code is as follows :

pragma solidity ^0.4.17;
// Minimum compiled version of the contract 
// Contract class name is equivalent to 
contract Faucet {

// Method name 
function withdraw(uint amount) public {

// Similar to if, If you are not satisfied, terminate 
require(amount <= 1000000000000000000);
// Launch a deal 
msg.sender.transfer(amount);
}
// The feedback method seems to be , There will be an error if the method is not called to initiate the transaction 
function () public payable {
}
}

The code may be red due to the version of the compiler , Need to Solidity Compiler Modified version inside

 Insert picture description here

3. Start up contract

Third tab Deploy
enviroment choice injected Web3, This time will automatically link MataMask
After the link is successful Account It will automatically fill in the current MataMask The account of Hash value
Finally, click Deploy
MataMask Automatically bring up a new contract , Be sure to have Eth, Or you can't afford Gas Will fail
After submitting the transaction successfully, wait for the miner to package the transaction ( It could be a long time )
After packing, you can Deployed Constracts See the contract and method in
It can also be in OR Where to fill in the contract Hash Address , Click on At Address You can see the contract

版权声明:本文为[Difficult to name]所创,转载请带上原文链接,感谢。 https://netfreeman.com/2022/03/202203220527197930.html