Rabet | Docs
Search…
Signing Transactions
Transactions are a formal action on a blockchain. They can contain a simple sending of Lumen (Payment Operation) or sending tokens creating data on the blockchain network and so on.
In Rabet, use the rabet.sign method to send a transaction.
This function accepts a transaction envelope XDR and network type(mainnet or testnet), When you put an XDR string and network type inside this method and call it, Rabet decodes it and shows its details to the user, if the user confirms and signs it, you receive the signed XDR.
You should only call the sign function after calling the connect function. Otherwise, it would return the not-connected error.
1
// Connect before signing
2
const xdr = 'AAAAAL...'; // Only string
3
const network = 'mainnet'; // mainnet / testnet
4
5
rabet.sign(xdr, network)
6
.then(result => console.log(`Signed xdr: ${result.xdr}`))
7
.catch(error => console.error(`Error: ${error.message}`));
Copied!
You can also use
StellarSdk.Networks.PUBLIC
or StellarSdk.Networks.TESTNET
for the netowrk parameter.
Example of the message that the user will receive when calling the sign function:
You can use StellarSdk to submit the transaction to the network. Like so:
1
var StellarSdk = require('stellar-sdk');
2
var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');
3
4
const xdr = 'AAAA...';
5
const envelope = StellarSdk.xdr.TransactionEnvelope.fromXDR(xdr, 'base64');
6
var transaction = new StellarSdk.Transaction(envelope, StellarSdk.Networks.TESTNET);
7
8
server
9
.submitTransaction(transaction)
10
.then((result) => {
11
console.log(result);
12
})
13
.catch((e) => {
14
console.log(e.response.data);
15
});
Copied!
You can learn more about Stellar SDKs here.
Last modified 11d ago
Copy link