Created
January 13, 2020 07:10
-
-
Save laalaguer/258693ebd5c609d82295af2931b63a3d to your computer and use it in GitHub Desktop.
Compound signature from user and sponsor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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