0

I'm not using omnicore by RPC calls, I dont want to put a server up and make those RPC calls, I want to make a simple transaction on the TetherUS(USDT) network, this is my code:

const getUnsignedTransaction = async (data) => {
  let { pubKey, fromAddr, toAddr, amount, fee, testnet } = data;
  let params = new URLSearchParams;
  params.append('transaction_version',1);
  params.append('currency_identifier',31);
  params.append('fee',fee);
  params.append('testnet',testnet);
  params.append('pubkey',pubKey);
  params.append('amount_to_transfer',amount);
  params.append('transaction_from',fromAddr);
  params.append('transaction_to',toAddr);
  return await Axios.post('/v1/transaction/getunsigned/0', params);
}

When I call this function above

  let a = await getUnsignedTransaction({
    amount:    '0.00001',
    fee:       '0.00005',
    testnet:   false,
    toAddr:    '1KH34S5mAmgAzu3mJAqrS3wjP15qYKZQXx',
    fromAddr:  '17UrxYAAF5WkjtFKeuZ2S7ojDWoJY2LunF',
 pubKey:'03f26647f3bbf4566318d00e2438036be0f1a68ee5deea604be6fa6cad68349888',
  }).then(e => e.data);
  console.log(a);

I got this response:

{ sourceScript:
   'OP_DUP OP_HASH160 4715b028de4327f5f87915d89d1d074db3f03992 OP_EQUALVERIFY OP_CHECKSIG',
  status: 200,
  unsignedhex:
   '0100000001131184d4a10bbf1acef3cb137d37ecc8f36cb3da208c9ebe86fb988821d532b40100000000ffffffff034d160000000000001976a9144715b028de4327f5f87915d89d1d074db3f0399288ac22020000000000001976a914c87aa36f1402052ef87ea433c2fa252ae9a9794988ac0000000000000000166a146f6d6e69000000000000001f00000000000003e800000000' }

Now here is the question: How can I make this unsigned raw transaction an valid transaction to the Tether network and so, broadcast this signed raw transaction

This is the blockexplorer I'm using: https://api.omniexplorer.info/#request-v1-transaction-pushtx


Code solution

As the @Raghav_Sood chosen answer, I had to use bitconjs-lib to wrap this transaction and to sign it.

For those who wanna see in the future how I made the transaction, was kinda this:

let tx  = bitcoinjs.Transaction.fromHex(raw);
let txb = bitcoinjs.TransactionBuilder.fromTransaction(tx);
txb.sign(0, keyPair)
let raw = txb.build().toHex();

let d = await pushtx(raw).then(e => e.data);

function pushtx

async function pushtx(raw) {
  let params = new URLSearchParams;
  params.append('signedTransaction',raw);
  return await Axios.post('/v1/transaction/pushtx/',params);
}
1

The only omni-specific thing in Omni/Tether txs is the OP RETURN, and a small dust output to the address you are sending the funds to. Both of these seem to check out in your tx (I'm assuming you're sending to 1KH34S5mAmgAzu3mJAqrS3wjP15qYKZQXx).

You should be able to just use the regular Bitcoind signing functionality (or whatever library you are using's wrapper of it). They don't require any special signatures.

  • omniexplorer.info/search/… – Alex Jul 22 '18 at 0:16
  • I was trying that, but in a different way, thanks. – Alex Jul 22 '18 at 0:16
  • I'll put the code later on, in the question. – Alex Jul 22 '18 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.