How to sign a transaction on an offline mechine and send it on an online mechine

in #steemlast year (edited)

Here is an example.

const from = 'ety001';
const to = 'ety001';
const amount = '0.001 STEEM';
const memo = '';
const wif = '';

let tx = {
    'operations': [
        [
            'transfer',
            {
                from,
                to,
                amount,
                memo,
            }
        ]
    ]
};

// prepare tx and sign it
steem.broadcast._prepareTransaction(tx).then( tx => {
    tx = steem.auth.signTransaction(tx, [wif]);
    // send tx to remote online server and broadcast.
    setTimeout(() => {
        steem.api.broadcastTransactionSynchronousAsync(tx).then(res => {
            console.log(res);
        });
    }, 5000);
});

We use steem.broadcast._prepareTransaction() and steem.auth.signTransaction() to sign a transaction on a offiline mechine.

Then we get parameter tx. It's a JSON type data. We can send this JSON data to an online mechine.

On the online mechine, we use steem.api.broadcastTransactionSynchronousAsync() broadcast JSON data to blockchain.


Thank you for reading. I'm a witness. You could find more on my site https://steem.fans

I would really appreciate your witness vote! You can vote by AuthSteem. Or open https://steemitwallet.com/~witnesses page, input ety001 to vote.

2.gif

Thank you!

Coin Marketplace

STEEM 0.19
TRX 0.18
JST 0.033
BTC 87757.32
ETH 3103.63
USDT 1.00
SBD 2.75