Attach data
Attach Data
With the SDK, you can also attach public data to payments. This data is uploaded to a public blockchain, meaning it cannot be modified or deleted. This can be used as a data timestamping service and can lend transparency to activity in your app.
Maxiumum attachment size
The maximum body request cannot exceed 1MB. That includes the attachment value with the rest of the JSON request.
You may attach data in the following formats:
attachment: { format: 'base64', value: 'ABEiM0RVZneImQCqu8zd7v8=' }
attachment: { format: 'hex', value: '0011223344556677889900AABBCCDDEEFF' }
attachment: { format: 'hexArray', value: ['0011223344556677889900AABBCCDDEEFF', '0011223344556677889900AABBCCDDEEFF', '0011223344556677889900AABBCCDDEEFF'] }
attachment: { format: 'json', value: {"param1": "value1", "param2": "value2"} }
To attach data, add an attachment
field to your payment parameters:
const {HandCashConnect} = require('@handcash/handcash-connect');
const handCashConnect = new HandCashConnect({
appId: '<app-id>',
appSecret: '<secret>',
});
const account = handCashConnect.getAccountFromAuthToken(token);
const paymentParameters = {
description: "Hold my beer!🍺",
payments: [
{ destination: 'nosetwo', currencyCode: 'DUR', sendAmount: 200 },
]
attachment: { format: 'json', value: {"param1": "value1", "param2": "value2"} },
};
const paymentResult = await account.wallet.pay(paymentParameters);
console.log(paymentResult);
// paymentResult
{
transactionId: '4c7b7cdc18702bb1a09c75a47bc2fa9630545761fbbd53b8c38735c73173e043',
note: 'Hold my beer!🍺',
type: 'send',
time: 1604958667,
satoshiFees: 113,
satoshiAmount: 10000,
fiatExchangeRate: 160.74284545024352,
fiatCurrencyCode: 'USD',
participants: [
{
type: 'user',
alias: 'nosetwo',
displayName: 'Nose two',
profilePictureUrl: 'https://res.cloudinary.com/hk7jbd3jh/image/upload/v1574787300/gntqxv6ed7sacwpfwumj.jpg',
responseNote: ''
}
],
attachments: [ { value: [Object], format: 'json' } ],
}
Updated 9 months ago