#
Pushing simple operation
If your case is to perform simple actions on your transaction or create a new transaction, you can use initialization with the wax base interface.
secondary
However it is recommended to use chain initialization due to automatic TaPos data fetching (and so we do in the example code below).
Below is an example of fully building a simple transaction using the basic ITransaction interface.
Test it yourself: src/typescript/transaction/working-with-transaction/pushing-simple-operation/simple-operation.ts
import { createHiveChain } from '@hiveio/wax';
// Initialize hive chain interface
const chain = await createHiveChain();
// Initialize a transaction object
const tx = await chain.createTransaction();
// Declare example operation
const operation = {
vote_operation: {
voter: "voter",
author: "test-author",
permlink: "test-permlink",
weight: 2200
}
};
// Push operation into the transction
tx.pushOperation(operation);
/*
Get a transaction object holding all operations and transaction
TAPOS & expiration data, but transaction is **not signed yet**
*/
const builtTx = tx.transaction;
console.log(builtTx.operations);
[
{
vote_operation: {
voter: 'voter',
author: 'test-author',
permlink: 'test-permlink',
weight: 2200
}
}
]
Test it yourself on github codespace: src/python/transaction/working_with_transaction/pushing_simple_operation/simple_operation/pushing_simple_operation.py
import asyncio
from wax import create_hive_chain
from wax.proto.operations import vote
# Initialize hive chain interface
chain = create_hive_chain()
async def main() -> None:
# Declare example operation
vote_operation = vote(
voter="voter",
author="test-author",
permlink="test-permlink",
weight=2200,
)
# Initialize a transaction object
tx = await chain.create_transaction()
# Push operation into the transction
tx.push_operation(vote_operation)
# Get a transaction object holding all operations and transaction TAPOS & expiration data, but transaction is **not signed yet**
build_tx = tx.transaction
print(build_tx.operations)
asyncio.run(main())
[
vote_operation
{
voter: "voter"
author: "test-author"
permlink: "test-permlink"
weight: 2200
}
]