Create a Stamp
About Stamps
The Stamp API allows you to easily upload a file to IPFS and stamp it on the IOTA tangle by creating an NFT.
- OTR
- HTTPS
To create a stamp, you must call stamp
on dataset(Dataset.STAMP)
. stamp
takes an object of type StampTangleRequest
as parameter in which you can specify the uri for the file you want to stamp.
const otrRequest = otr(otrAddress)
.dataset(Dataset.STAMP)
.stamp({ uri: 'https://www.africau.edu/images/default/sample.pdf' });
stamp
returns an oject of type OtrRequest
<
StampTangleRequest
>
.
When you create a stamp, you can specify the number of days the stamped file should be stored. If the OTR contains more funds as needed, the remaining funds will be returned. If you don't specify the number of days, the stamped file will be stored for the total time you paid for in the OTR.
To create a stamp, you must call stamp
on dataset(Dataset.STAMP)
. stamp
takes an object of type Build5Request
<
StampRequest
>
as parameter in which you can specify the file you want to stamp.
response = await https(origin)
.project(SoonaverseApiKey[origin])
.dataset(Dataset.STAMP)
.stamp({
address: address.bech32,
signature: userSign.signature,
publicKey: {
hex: userSign.publicKey,
network: Network.RMS,
},
body: {
file: 'https://www.africau.edu/images/default/sample.pdf',
network: Network.RMS,
},
});
stamp
returns an oject of type Transaction
.
Full How-To Code
- OTR
- HTTPS
import { Dataset } from '@build-5/interfaces';
import { Build5, SoonaverseOtrAddress, otr } from '@build-5/sdk';
async function main() {
const origin = Build5.TEST;
// @ts-ignore
const otrAddress = SoonaverseOtrAddress[origin];
console.log('Create stamp under your project...');
try {
const otrRequest = otr(otrAddress)
.dataset(Dataset.STAMP)
.stamp({ uri: 'https://www.africau.edu/images/default/sample.pdf' });
const fireflyDeeplink = otrRequest.getFireflyDeepLink();
console.log(fireflyDeeplink);
} catch (error) {
console.error('Error: ', error);
}
}
main().then(() => process.exit());
import { Dataset, Network, Transaction } from '@build-5/interfaces';
import { Build5, SoonaverseApiKey, https } from '@build-5/sdk';
import { address } from '../../utils/secret';
import { walletSign } from '../../utils/utils';
async function main() {
const origin = Build5.TEST;
let response: Transaction;
const userSign = await walletSign(address.bech32, address);
console.log('Create stamp under your project...');
try {
response = await https(origin)
.project(SoonaverseApiKey[origin])
.dataset(Dataset.STAMP)
.stamp({
address: address.bech32,
signature: userSign.signature,
publicKey: {
hex: userSign.publicKey,
network: Network.RMS,
},
body: {
file: 'https://www.africau.edu/images/default/sample.pdf',
network: Network.RMS,
},
});
console.log(
'Sent: ',
response.payload.amount,
' to ',
response.payload.targetAddress,
', full order object: ',
response,
);
} catch (error) {
console.error('Error: ', error);
}
}
main().then(() => process.exit());