It is possible to create and store a signed transaction and broadcast it later (maximum allowed delay is one hour or 3600 seconds).
At the beginning, the current block number and prefix has to be fetched from the api node.
Then the transaction can be created, signed and stored in a text file.
This allows using beem with other libraries for broadcasting.
import time
from beembase import operations
from beem.transactionbuilder import TransactionBuilder
from beem.steem import Steem
from beem.nodelist import NodeList
from beembase.transactions import getBlockParams
import json
wif = "5xxx"
if __name__ == "__main__":
stm_online = Steem()
ref_block_num, ref_block_prefix = getBlockParams(stm_online)
print("ref_block_num %d - ref_block_prefix %d" % (ref_block_num, ref_block_prefix))
stm = Steem(offline=True)
op = operations.Transfer({'from': 'beembot',
'to': 'holger80',
'amount': "0.001 SBD",
'memo': ""})
tb = TransactionBuilder(steem_instance=stm, expiration=3600)
tb.appendOps([op])
tb.appendWif(wif)
tb.constructTx(ref_block_num=ref_block_num, ref_block_prefix=ref_block_prefix)
tx = tb.sign(reconstruct_tx=False)
params = (tx.json())
broadcast_json = {"jsonrpc":"2.0", "method":"condenser_api.broadcast_transaction", "params":[params], "id":1}
with open("broadcast_transfer.json", "w") as f:
f.write(json.dumps(broadcast_json))
This script fetches the ref_block_num
and ref_block_prefix
and builds a json dictionary which contains the signed transaction. The json is written into a text file broadcast_transfer.json
.
It is only possible to send a transaction once. Resending will lead to Duplicate transaction check failed
. The @
sign means that the following is not a text for sending but a file name.
curl -s --data "@broadcast_transfer.json" https://api.steemit.com
The content of this file is read and then broadcasted to the node.
It worked.
This post has been just added as new item to timeline of beem on Steem Projects.
If you want to be notified about new updates from this project, register on Steem Projects and add beem to your favorite projects.
Can you do incremental signing with this too?
Hi @holger80!
Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your UA account score is currently 6.861 which ranks you at #90 across all Steem accounts.
Your rank has improved 2 places in the last three days (old rank 92).
In our last Algorithmic Curation Round, consisting of 219 contributions, your post is ranked at #16.
Evaluation of your UA score:
Feel free to join our @steem-ua Discord server
Great work. May I suggest using this in a proof of concept for this task request. The 34 STEEM bounty is supposed to end in 26 hours and a bit, but if before the deadline anyone tells me they are working on it and need a few more days, I'll be happy to extend the deadline a bit.