Send Transaction
Let's send a transaction.
When submitting a transaction, you must specify the TransactionType
field, which indicates what type of transaction, and the Account
field, which indicates the account to which the transaction is being submitted.
Some fields, such as the Fee
field, which indicates the transaction fee to be consumed, and the Sequence
field, which uniquely identifies the transaction for the account, can be filled in automatically.
Try to send the simplest transaction here.
AccountSet
transaction is a transaction to change account settings.
If a transaction is sent without specifying the account settings, the account settings will not be changed at all, only the transaction fee will be consumed.
First, use Validate
button to check that the JSON data for the transaction is correct.
Then use Autofill
button to set the autofill field, and use Sign
button to sign the transaction.
Finally use Submit
button to submit the transaction.
Transaction Result:
Example1
const { Client, Wallet } = require('xrpl')
const client = new Client('wss://testnet.xrpl-labs.com')
const wallet = Wallet.fromSeed('<seed>')
const txn = {
TransactionType: 'AccountSet',
Account: 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59',
}
client.connect().then(() => {
client.autofill(txn).then((txn) => {
const { tx_blob } = wallet.sign(txn)
client.submit(tx_blob)
})
})
Example2
const { Client, Wallet } = require('xrpl')
const client = new Client('wss://testnet.xrpl-labs.com')
const wallet = Wallet.fromSeed('<seed>')
client.connect().then(() => {
client
.submitAndWait( // autofill, sign, submit, wait
{
TransactionType: 'AccountSet',
Account: 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59',
},
{ wallet }
)
.then((response) => {
console.log(response)
})
})