1

I am building an app that allows you to upload a photo and mint it as an NFT on Solana. I am trying to add funds to a BundlrStorageDriver object like this:

const storage = metaplex.storage().driver() as BundlrStorageDriver;
storage.fund(1000)

Which should work according to this documentation.

enter image description here

But I am getting this error: enter image description here

I looked online and couldn't find any references to BundlrStorageDriver's native functions or the data type 'Amount', so not sure how to proceed from here. What should I do? Thanks!

2
  • 1
    Actually I tried this and it worked. (await storage.bundlr()).fund(1000);. Gonna go forward with that for now! Commented Jul 20, 2022 at 22:13
  • Better to post resolutions as an answer than a comment!
    – trent.sol
    Commented Jul 21, 2022 at 0:44

1 Answer 1

0

Looking at the definition for the Amount structure and friends,

export type Amount<T extends Currency = Currency> = {
  basisPoints: BigNumber;
  currency: T;
};

export type Currency = {
  symbol: string;
  decimals: number;
  namespace?: 'spl-token';
};

export type SplTokenCurrency = {
  symbol: string;
  decimals: number;
  namespace: 'spl-token';
};
export type SplTokenAmount = Amount<SplTokenCurrency>;

export const SOL = {
  symbol: 'SOL',
  decimals: 9,
} as const;
export type SolCurrency = typeof SOL;
export type SolAmount = Amount<SolCurrency>;

Looks like it's just a wrapper to indicate if you are funding in SOL or with other SPL-tokens (looks like they at least support USDC).

So the correct way of calling the fund function while funding with SOL should be:

const amount: SolAmount = {
    basisPoints: new BigNumber(2000),
    currency: SOL
};
await (await bundlrStorage.bundlr()).fund(amount);

It should be noted that BigNumber doesn't come from the bignumber.js library, which is common, It is instead a type inside the same Metaplex library.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.