Protobuf 定义

Vision Network虚拟机运行的智能合约兼容以太坊智能合约特性,以protobuf的形式定义合约内容:

message SmartContract {
  message ABI {
    message Entry {
      enum EntryType {
        UnknownEntryType = 0;
        Constructor = 1;
        Function = 2;
        Event = 3;
        Fallback = 4;
      }
      message Param {
        bool indexed = 1;
        string name = 2;
        string type = 3;
        // SolidityType type = 3;
      }
      enum StateMutabilityType {
        UnknownMutabilityType = 0;
        Pure = 1;
        View = 2;
        Nonpayable = 3;
        Payable = 4;
      }

      bool anonymous = 1;
      bool constant = 2;
      string name = 3;
      repeated Param inputs = 4;
      repeated Param outputs = 5;
      EntryType type = 6;
      bool payable = 7;
      StateMutabilityType stateMutability = 8;
    }
    repeated Entry entrys = 1;
  }
  bytes origin_address = 1;
  bytes contract_address = 2;
  ABI abi = 3;
  bytes bytecode = 4;
  int64 call_value = 5;
  int64 consume_user_resource_percent = 6;
  string name = 7;
  int64 origin_entropy_limit = 8;
}

origin_address: 合约创建者地址
contract_address: 合约地址
abi:合约所有函数的接口信息
bytecode:合约字节码
call_value:随合约调用传入的vs金额
consume_user_resource_percent:开发者设置的调用者的资源扣费百分比
name:合约名称
origin_entroy_limit: 开发者设置的在一次合约调用过程中自己消耗的entropy的上限,必须大于0。对于之前老的合约,deploy的时候没有提供设置该值的参数,会存成0,但是会按照1000万entropy上限计算,开发者可以通过updateEntropyLimit接口重新设置该值,设置新值时也必须大于0

通过另外两个grpc message类型 CreateSmartContract 和 TriggerSmartContract 来创建和使用smart contract