Upgrade to Pro — share decks privately, control downloads, hide ads and more …

zemi-2

 zemi-2

hibjhs

May 24, 2022
Tweet

More Decks by hibjhs

Other Decks in Programming

Transcript

  1. Ropstenノードの構築 sudo add-apt-repository -y ppa:ethereum/ethereum sudo apt update sudo aptt

    install ethereum でインストールしておく その後~/Ethereumを作成し~/Ethereum/ropstenを作成する geth --ropsten --syncmode "snap" --datadir "./ropsten" --http --http.addr "localhost" --http.port "8545" --http.api "eth,net,web3,admin,miner,txpool,personal" --allow-insecure-unlock -- console 2>> ./ropsten/geth_err.log を実行して To exit, press ctrl-d or type exit がでたら成功
  2. Ropstenによる送金 > eth.sendTransaction({from: eth.accounts[2], to: eth.accounts[0], value: web3.toWei(0.001, "ether")}) "0x05ee5ac1df84e9b1ee359b53252f6ee7bd834721db609dc32dd9f38ad2e8139f"

    /トラン ザクション > eth.getBalance(alice) 1000000000000000 > eth.getBalance(takahashi) 9998901468041349000 gas代がかかっているので0.001ethだけ引かれることはない
  3. privateネットを立てる myGenesis.jsonを作成 (初期化)geth --datadir ~/eth_private_net init ~/eth_private_net/myGenesis.json (構築)geth --networkid "15"

    --nodiscover --datadir "~/eth_private_net" console 2>> ~/eth_private_net/geth_err.log Welcome to the Geth JavaScript console! がでたら成功
  4. // SPDX-License-Identifier: CC-BY-SA-4.0 // Version of Solidity compiler this program

    was written for pragma solidity >=0.4.16 <0.9.0; // Our first contract is a faucet! contract Faucet { // Accept any incoming amount入金額の受け入れ receive() external payable {} // Give out ether to anyone who asks要求する人にイーサを与える function withdraw(uint withdraw_amount) public { // Limit withdrawal amount引き出し額の制限 require(withdraw_amount <= 100000000000000000); // Send the amount to the address that requested itリクエストしたアドレスに金額を送る payable(msg.sender).transfer(withdraw_amount);