Skip to content

Instantly share code, notes, and snippets.

@laalaguer
Created January 13, 2020 07:10
Show Gist options
  • Save laalaguer/258693ebd5c609d82295af2931b63a3d to your computer and use it in GitHub Desktop.
Save laalaguer/258693ebd5c609d82295af2931b63a3d to your computer and use it in GitHub Desktop.
Compound signature from user and sponsor
// Fetch the sponsor signature.
const sponsorSignature = await getSponosrSignature(
'0x'+originAddress.toString('hex'),
txBody
)
// Compose a combined signature of user + sponsor.
const sig = Buffer.concat([
originSignature,
Buffer.from(sponsorSignature, 'hex')
])
// Mount on the combined signature.
tx.signature = sig
// Convert the tx to raw format.
const rawTx = '0x' + tx.encode().toString('hex')
// Submit the raw transaction by hand to the test-net.
const url = 'https://sync-testnet.vechain.org/transactions'
fetch(url, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({'raw': rawTx})
}).then(response => {
response.text().then(r => {console.log(r)})
}).catch(err => {
console.log('err', err)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment