更新时间:2023-03-24 GMT+08:00
分享

利用合约发送交易

  1. 背书消息构建

    • 接口函数

      func (msg *ContractRawMessage) BuildInvokeMessage(chainID string, name string, function string, args []string) (*common.RawMessage, error)

    • 参数说明

      参数

      类型

      说明

      chainID

      string

      链ID。

      name

      string

      合约名称。

      function

      string

      调用合约中的方法名。

      args

      []string

      合约方法参数。

    • 返回值

      类型

      说明

      *common.RawMessage

      背书请求需发送的消息。

      error

      发送成功返回类型为nil,反之返回error。

  2. 背书请求消息发送。

    • 接口函数
      func (action *ContractAction) Invoke(rawMsg *common.RawMessage) (*common.RawMessage, error)
    • 参数说明

      参数

      类型

      说明

      rawMsg

      *common.RawMessage

      上述背书请求需发送的消息。

    • 返回值

      类型

      说明

      *common.RawMessage

      背书请求需发送的消息。

      error

      发送成功返回类型为nil,反之返回error。

  3. 交易消息构建。

    • 接口方法
      func (msg *ContractRawMessage) BuildTxRawMsg(rawMessages []*common.RawMessage) (*TxRawMsg, error)
    • 参数说明

      参数

      类型

      说明

      rawMessages

      []*common.RawMessage

      背书请求返回结果集合。

    • 返回值

      类型

      说明

      *TxRawMsg

      包含交易hash的交易请求信息,该消息使用transaction接口发送。

      error

      构建成功返回类型为nil,反之返回error。

  4. 交易消息发送。

    • 接口方法
      func (action *ContractAction) Transaction(rawMsg *common.RawMessage) (*common.RawMessage, error)
    • 参数说明

      参数

      类型

      说明

      rawMsg

      *common.RawMessage

      上述生成的交易消息。

    • 返回值

      类型

      说明

      *common.RawMessage

      用于获取包含发送结果的消息。

      error

      发送成功返回类型为nil,反之返回error。

分享:

    相关文档

    相关产品