Requests a payment from the users wallet to a set of given outputs. Internally a BIP-0044 account discovery is performed and user is presented with a list of accounts. After account selection user is presented with list of fee selection. After selecting a fee transaction is signed and returned in hexadecimal format. Change output is added automatically, if needed.
ES6
const result = await TrezorConnect.composeTransaction(params);CommonJS
TrezorConnect.composeTransaction(params).then(function(result) {
});outputs— obligatoryArrayof recipients Objects described belowcoin— obligatorystringdetermines network definition specified in coins.json file. Coinshortcut,nameorlabelcan be used.push— optionalbooleandetermines if composed transaction will be broadcasted into blockchain.
regular outputamount- obligatorystringvalue to send in satohosiaddress- obligatorystringrecipient address
send-max- spends all available inputs from accounttype- obligatory withsend-maxvalueaddress- obligatorystringrecipient address
opreturn- read moretype- obligatory withopreturnvaluedataHex- optionalhexadecimal stringwith arbitrary data
Send 0.002 BTC to "18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2"
TrezorConnect.composeTransaction({
outputs: [
{ amount: "200000", address: "18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2" }
]
coin: "btc",
push: true
});{
success: true,
payload: {
signatures: Array<string>, // signer signatures
serializedTx: string, // serialized transaction
txid?: string, // blockchain transaction id
}
}Error
{
success: false,
payload: {
error: string // error message
}
}version 4 and below:
var recipients = [{
amount: 200000,
address: "18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2"
}];
TrezorConnect.setCurrency("btc");
TrezorConnect.composeAndSignTx(recipients, function(result) {
result.signatures // not changed
result.serialized_tx // renamed to "serializedTx"
// added "txid" field if "push" is set to true
});version 5
var recipients = [{
amount: "200000",
address: "18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2"
}];
// params are key-value pairs inside Object
TrezorConnect.composeTransaction({
outputs: recipients,
coin: "btc"
}).then(function(result) {
...
})