ethereum(以太坊)(基础)--容易忽略的坑

Posted eilinge

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ethereum(以太坊)(基础)--容易忽略的坑相关的知识,希望对你有一定的参考价值。

pragma solidity ^0.4.0;

contract base{
    address public _owner=msg.sender;
    uint _a;
    string internal _b ;
    uint private _c;
    //uint external _d;ParserError: Expected identifier but got ‘external‘
    
    function base() {
        _a =10;
        //uint  _d public;Expected ‘;‘ but got ‘public‘
        string _f;
    }

    function getA() public view returns (uint){
        return _a;
    }
    
    function setA(uint c) internal{
        _a=c;
    }
    
    //modifier OnlyAdmin() private{Expected ‘{‘ but got ‘private‘
    modifier OnlyAdmin(){
        require(_owner == msg.sender);
        _;
    }
    
    function kill() OnlyAdmin() external{
        setA(6);
        this.getA();
        selfdestruct(msg.sender);
    }
}
contract base1 is base{
    function getA() public view returns(uint){
        //return _c;DeclarationError: Undeclared identifier. Did you mean "_a" or "_b"?
        //return _b;Overriding function return types differ:覆盖函数返回类型不同
        return _a;
    }
    function getE(){
        this.kill();
        this.getA();
        //this.setA(20);Member "setA" not found or not visible after argument-dependent lookup in contract base1
    }
}

contract base2{
    
    uint public _e;
    function getE(){
        //this.getA();Member "getA" not found or not visible after argument-dependent lookup in contract base2
    }
}
//contract base2 is base1,base{ Linearization of inheritance graph impossible:继承图的线性化是不可能的
contract base3 is base,base1{
    uint public _e;
}

 

以上是关于ethereum(以太坊)(基础)--容易忽略的坑的主要内容,如果未能解决你的问题,请参考以下文章

Ethereum 基础

(转)写文章 以太坊(Ethereum)创世揭秘 以太坊(Ethereum)创世揭秘

搭建Ethereum以太坊测试网络Rinkeby节点

Ethereum以太坊ERC20 Token标准完整说明

Ethereum for web developers

open-ethereum-pool以太坊矿池源码分析-redis模块