Stellar

Sign Transaction

The D'CENT Web SDK provides functions for signing transaction of coins.

getStellarSignedTransaction()

Supported Coin Type

  • STELLAR

Parameters

  • transactionJson: this value conforms JSON format of Transaction Types in Stellar Docs

Requirements

  • D'CENT Bridge version 1.4.0 or higher is required.

  • D'CENT Biometric Wallet version 2.20.0 or higher is required.

Useage

const _buf2hex = (buffer) => { // buffer is an ArrayBuffer
    return Array.prototype.map.call(new Uint8Array(buffer), x => ('00' + x.toString(16)).slice(-2)).join('');
}
const server = new StellarSdk.Server('https://horizon.stellar.org')
const account = await server.loadAccount(address)

// Operation
const operationXdr = StellarSdk.Operation.createAccount({
    destination: toAddr,
    startingBalance: amount
})

// Builder
const transactionBuilder = new StellarSdk.TransactionBuilder(account, { 
    fee: StellarSdk.BASE_FEE,
    networkPassphrase: StellarSdk.Networks.TESTNET
})
.addOperation(operationXdr)
.setTimeout(300)
.build()

const unsignedTx = _buf2hex(transactionBuilder.signatureBase())

const transactionJson = {
    unsignedTx: unsignedTx,
    fee: StellarSdk.BASE_FEE
    path: `m/44'/148'/0'`,
}

var result
try {
    result = await DcentWebConnector.getStellarSignedTransaction(transactionJson);    
} catch (e) {
    console.log(e)
    result = e
}

Returned response object

{
    "header": {
        "version": "1.0",
        "response_from": "stellar",
        "status": "success"
    },
    "body": {
        "command": "transaction",
        "parameter": {
            "signed_tx": "0x9b1cb82eb924178980b1d35f99ae24142d25ba08efabd1dfe7f4741028d03f3fe80770b395176b9d49381d98660e2746d38986b4e31af738524ca0936a7aa901",
            "pubkey": "0x283957814f67abe6eda79128d3d54655a1ec8c595aece2c12f0848461a4ef659"
        }
    }
}

Last updated