创建一个未签名的交易,用于 Bancor 协议下交易所上的代币交易。
用法
visionWeb.transactionBuilder.tradeExchangeTokens(
exchangeID,
tokenId,
tokenAmountSold,
tokenAmountExpected,
ownerAddress,
options
);
入参
参数 | 描述 | 类型 | 默认值 |
---|---|---|---|
exchangeId | 交易对 id | number | - |
tokenId | 代币 Id | number | string | - |
tokenAmountSold | 售出的代币数量 | number | - |
tokenAmountExpected | 预期的代币数量 | number | - |
ownerAddress | 代币所有者的地址 | string | 默认账户地址 |
options | 可选参数,具体参数见下方 | object | - |
options 参数
参数 | 描述 | 类型 | 默认值 |
---|---|---|---|
permissionId | 设置多重签名时使用 | number | - |
返回值
object,创建的 transaction 对象。
示例
visionWeb.transactionBuilder.tradeExchangeTokens(1,"1000001",1000,1000);
> {
"visible": false,
"txID": "33ee92c191bf00f4b06daccc5c3adb85c33f9b997fcf8822b4ec93ae0927cef8",
"raw_data": {
"contract": [
{
"parameter": {
"value": {
"exchange_id": 1,
"token_id": "31303030303031",
"expected": 1000,
"owner_address": "4653cd48c2723cb985679f4e44d99c64d22d89f41d",
"quant": 1000
},
"type_url": "type.googleapis.com/protocol.ExchangeTransactionContract"
},
"type": "ExchangeTransactionContract"
}
],
"ref_block_bytes": "c778",
"ref_block_hash": "db086b31f0f10f69",
"expiration": 1608469779000,
"timestamp": 1608469720479
},
"raw_data_hex": "0a024a572208e75bcd33afa55f3340b8a49482e82e5a65080112610a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412300a154653cd48c2723cb985679f4e44d99c64d22d89f41d1215462d7a77f8bef6fe225bf5e353dd6a380f588a1496180a709fdb9082e82e"
}