Blockchain Research (iii) building a simple smart contract based on the Ethereum private chain

Source: Internet
Author: User

1. Transfer of account wallet to each other

Open Ethereum-wallet.exe


Click Account 1


Click Copy Address


You are prompted to test the network, do not transfer to the real etheric currency to this account

Click Copy anyway duplicate address: 0x102f3f760a9f34b0b6c917ee20f8bc155e39e8d3

Click Send to insert the copied address into the To input box


Enter the amount you want to transfer in amount, such as 2018


Click Show more OPTIONS to add additional data sent with the transaction. If you don't know what it is, don't touch it, or something bad will happen.


Swipe left and right select FEE This is the maximum amount that is used to process this transaction. Your transaction will be mined within 30 seconds. The higher the fee, the faster, but only applicable to the public chain


Click on the bottom of the blue send sent, enter the password and wait for the miners to confirm, confirm the account will receive 2018 ether coins.




You can see the most recent transactions at the bottom of the wallet, and you can see some specific trading information after clicking on it.


The bottom of send data appears only after you fill in the Show more options Data box in Send, but it appears that you can only enter the hexadecimal number


2. Deploy Smart Contracts

Click Contracts on the main page to enter the Smart Contract Management page


Click Deploy NEW contract to start deploying only contracts


From select the account to deploy the smart contract, enter the smart contract code in solidity contract source code, select the handling fee in select fee, so the deployment contract is for money ...


Since the smart contract can only be written in solidity language, the official Chinese document of solidity is attached here.

Address: http://wiki.jikexueyuan.com/project/solidity-zh/

After entering the contract and selecting the contract you created on the right, you can fill in some parameters


The code is as follows:

pragma solidity ^0.4.18;
    Contract MyTokenTest1 {/* This creates a maps with all balances */mapping (address = uint256) balanceof;  /* This has some basic information about the contract */string public name;
    string public symbol;
    Uint8 public decimals; /* This keep track of activities happening int the contract */event Transfer1 (address indexed _from, address indexed
    
    _to, uint256 _value);
    /* Constructor function MyTokenTest1 () public {Balanceof[msg.sender] = 19940326;
        }*//* Supply it as a parameter for the function function MyTokenTest1 (uint256 initialsupply) public {
    Balanceof[msg.sender] = initialsupply; }*//* Initializes contract with initial supply tokens to the creator of the contract * * Function mytokentest  1 (uint256 initialsupply, String tokenname, String tokensymbol, Uint8 decimalunits) public{Balanceof[msg.sender] =
        initialsupply; name = Tokenname;
        symbol = Tokensymbol;
    decimals = decimalunits;
        }/* This transfer balance with in the account*/function transfer1 (address _to, uint256 _value) public{ /*to check for overflows and to avoid the acount becomes zero*/require (Balanceof[msg.sender] >= _value &am
        
        p;& balanceof[_to] + _value >= balanceof[_to]);
        Balanceof[msg.sender]-= _value;
        
        BALANCEOF[_TO] + = _value;
    /* Notify Anyone listening that this transfer took place */Transfer1 (Msg.sender, _to, _value); }

}

Click the bottom Blue Deploy button when you are finished typing


Enter the password, SEND TRANSACTION, and the deployment is successful.

3. Run the Smart contract

Click Contracts, click on the custom contracts to select the contract you just established


In write to contract on the right, select function is the one you just created and fills in the address and value


Click Execute to execute, enter password after send TRANSACTION


Tick the Watch contract events in latest events below to see the events you just tracked


After taking a few minutes to confirm, you can see that the success has been sent



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.