Skip to main content

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.

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>.

Days Parameter

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.

Full How-To Code

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());