from wax import create_wax_foundation, create_hive_chain# For offline operations (transaction building)wax = create_wax_foundation()# For online operations (broadcasting, API calls)chain = create_hive_chain()
2
Build a transaction
Create a transaction and add operations. This example creates a vote operation:
from wax.proto.operations import vote_operation# Create a transactiontx = wax.create_transaction()# Add a vote operationtx.push_operation( vote_operation( voter="alice", author="bob", permlink="example-post", weight=10000 # 100% vote ))
The weight field accepts values from -10000 (100% downvote) to 10000 (100% upvote).
3
Sign the transaction
Sign the transaction with Beekeeper wallet:
from beekeepy import create_wallet# Create a Beekeeper wallet sessionasync with create_wallet() as wallet: # Import your key public_key = await wallet.import_key("5JYourPrivateKeyHere...") # Sign the transaction await tx.sign(wallet, public_key)
Never hard-code private keys in production. Use environment variables or secure key management.
4
Broadcast to the network
Send your signed transaction to the Hive blockchain:
Here are some other common operations you might want to try:
Transfer tokens
Transfer HIVE, HBD, or HIVE POWER between accounts:
TypeScript
Python
tx.pushOperation({ transfer: { from_account: "alice", to_account: "bob", amount: wax.hiveCoins(10), // 10 HIVE memo: "Thanks for your help!" }});
from wax.proto.operations import transfer_operationtx.push_operation( transfer_operation( from_account="alice", to_account="bob", amount=wax.hive(10), # 10 HIVE memo="Thanks for your help!" ))
Create a blog post
Publish content to the Hive blockchain:
TypeScript
Python
tx.pushOperation({ comment: { parent_author: "", parent_permlink: "blockchain", author: "alice", permlink: "my-first-post", title: "My First Post on Hive", body: "This is the content of my post...", json_metadata: JSON.stringify({ tags: ["blockchain", "hive"], app: "my-app/1.0.0" }) }});
from wax.proto.operations import comment_operationimport jsontx.push_operation( comment_operation( parent_author="", parent_permlink="blockchain", author="alice", permlink="my-first-post", title="My First Post on Hive", body="This is the content of my post...", json_metadata=json.dumps({ "tags": ["blockchain", "hive"], "app": "my-app/1.0.0" }) ))