How to Integrate VIP-191 (III)
Sponsor’s Server Code
const express = require('express')
const cry = require('thor-devkit/dist/cry')
const Transaction = require('thor-devkit/dist/transaction').Transaction
const app = express()
app.use(express.json())
const port = 3000
app.post('/', function(req, res) {
// Re-construct the transaction from the request.
const tx = new Transaction(req.body['txBody'])
// Extract 'sender' address from request.
const sender = req.body['sender']
// Compute the sponsor hash.
const sponsorHash = tx.signingHash(sender)
// Sponsor account (with money):
// 0x126cdb344f476f25b9fb2050513f425a82f71046
const sponsorPriv = Buffer.from(
'5df5e7f22a71dfd3d032ff5eb9dfc7dbe9c950e0671745826639a0423cd45d7f',
'hex'
)
// Compute the sponsor signature with hash+private key.
const signature = cry.secp256k1.sign(sponsorHash, sponsorPriv)
// Send back the signature.
res.send({
'sponsor_signature': signature.toString('hex')
})
})
app.listen(port, () => console.log(`Example app listening on port ${port}!`))Back to the User’s side
An Example Result

Conclusion
Last updated
Was this helpful?