Provider

Nintondo Wallet APICopied!

This documentation is here to help you learn how to create applications for the Nintondo Wallet.

Getting StartedCopied!

Installation

npm i nintondo-sdk

Usage (manual method)

import { initNintondo } from "nintondo-sdk";

// It will return Nintondo instance if extension is already injected to the website
const nintondo: Nintondo | undefined = initNintondo();

Using React.Context (for React\Next.JS projects)

import { useNintondo, NintondoProvider } from "nintondo-sdk/react";

const Layout = () => {
  return (
    <NintondoProvider>
      <AppEntyPoint />
    </NintondoProvider>
  );
};

const AppEntyPoint = () => {
  const { isConnected, nintondo } = useNintondo();

  return (
    <div>
      {nintondo && <div>Nintondo injected</div>}
      {isConnected && <div>Nintondo connected</div>}
    </div>
  );
};

MethodsCopied!

connectCopied!

nintondo.connect() => Promise<string>

The address of the connected account.

Parameters

Returns

none

Promise returns string

The address of the connected account.

Example

await nintondo.connect();

> 'tbel1qxdp6v2u0q0tthc67e8sz2t3udykz99yrmnmvc5'


getBalanceCopied!

nintondo.getBalance() => Promise<number>

The get balance of the connected account.

Parameters

Returns

none

Promise returns number

The balance of the connected account.

Example

await nintondo.getBalance();

> 38285545404138


getAccountNameCopied!

nintondo.getAccountName() => Promise<string>

To get the current account name from the Nintondo provider.

Parameters

Returns

none

Promise returns string

The name of the connected account.

Example

await nintondo.getAccountName();

> 'Account 1'


isConnectedCopied!

nintondo.isConnected() => Promise<boolean>

To get the connection state from the Nintondo provider.

Parameters

Returns

none

Promise returns boolean

The connection state.

Example

await nintondo.isConnected();

> true


getAccountCopied!

nintondo.getAccount() => Promise<string =>

To get the current account from the Nintondo provider.

Parameters

Returns

none

Promise returns string

The address of the connected account.

Example

await nintondo.getAccount();

> 'tbel1qxdp6v2u0q0tthc67e8sz2t3udykz99yrmnmvc5'


getPublicKeyCopied!

nintondo.getPublicKey() => Promise<string>

To get the public key of the connected account from the Nintondo provider.

Parameters

Returns

none

Promise returns string

The public key of the connected account.

Example

await nintondo.getPublicKey();

> '02e2eac63c70b030f7ed7d1b37a3v56002dcc986e43c35c704532cf913e9dbh098'


getVersionCopied!

nintondo.getVersion() => Promise<string>

To get the version of the Nintondo provider.

Parameters

Returns

none

Promise returns string

The version of the Nintondo provider in the format x.x.x.

Example

await nintondo.getVersion();

> '0.2.9.2'


createTxCopied!

nintondo.createTx(payload: CreateTxPayload) => Promise<string>

To create a transaction.

Parameters

Returns

to: addresss; the address to send

amount: number; the satoshis to send

recaiverToPayFee: boolean; include fee in the amount

feeRate: number; the network fee rate

Promise returns SignedTxHex = string

The signed transaction hex.

Example

await nintondo.createTx({
    to: "EMpxzi7FujHsQHbrZy7wsuiRHFsvxKZSaB",
    amount: 10_000_000,
    receiverToPayFee: true,
    feeRate: 10
});

> '01000000058661950a3f261f4bbded75684...'


signMessageCopied!

nintondo.signMessage(message: string) => Promise<string>

To sign a message.

Parameters

Returns

message: string ; The message to sign.

Promise returns string

The signature message.

Example

await nintondo.signMessage("nintondo");

> 'UoQCs9wqDTsyt/3dinivJCO37fuKfqJSVyzNMSS8BrARECNLDf04Od5si0dsJ1RuE8JT/lDWnaJZRcV9WPMkyA=='


calculateFeeCopied!

nintondo.calculateFee(psbtHex: SignedPsbtBase64, feeRate: number) 
=> Promise<number>

To calculate the fee of a transaction.

Parameters

Returns

message: string ; The message to sign.

Promise returns number

The fee of the transaction.

Example

await nintondo.calculateFee("xxxxxxxx", 54)

> 5454


signPsbtCopied!

nintondo.signPsbt(
    psbtBase64: string,
    options?: SignPsbtOptions) => Promise<string>

To sign a PSBT.

Parameters

Returns

psbtBase64 - string: the hex string of psbt to sign

  • options

    • autoFinalized - boolean: whether finalize psbt after signing, default is true

    • toSignInputs - array:

      • index - number: which input to sign

      • address - string: (at least specify either an address or a publicKey) Which corresponding private key to use for signing

      • publicKey - string: (at least specify either an address or a publicKey) Which corresponding private key to use for signing

      • sighashTypes - number[]: (optionals) sighashTypes

      • disableTweakSigner - boolean :(optionals) Default value is false. Setting it true allows the use of the original private key when signing taproot inputs.

Promise returns SignedPsbtBase64 = string

The signed PSBT base64 string.

Example

await nintondo.signPsbt("xxxxxxxx",{toSignInputs:[
{index:0,publicKey:"xxxxxx",disableTweakSigner:true}]})


inscribeTransferCopied!

nintondo.inscribeTransfer(tokenName: string) => Promise<nubmer>

To inscribe a transfer.

Parameters

Returns

tokenName - string ; The token name to inscribe the transfer.

Promise returns mintedAmount: number

The inscribed transfer result.

Example

await nintondo.inscribeTransfer("nint");

> {mintedAmount: 1}


multiPsbtSignCopied!

nintondo.multiPsbtSign(payload: MultiSignPsbtOptions[]) => Promise<string>

To sign multiple PSBT's. This method will traverse all inputs that match the current address to sign.

Parameters

Returns

psbtBase64 - string[]: the hex strings of psbt to sign

options - object[]: the options of signing psbt

  • autoFinalized - boolean: whether finalize psbt after signing, default is true

  • toSignInputs - array:

    • index - number: which input to sign

    • address - string: (at least specify either an address or a publicKey) Which corresponding private key to use for signing

    • publicKey - string: (at least specify either an address or a publicKey) Which corresponding private key to use for signing

    • sighashTypes - number[]: (optionals) sighashTypes

    • useTweakedSigner - boolean :(optionals) . By setting useTweakedSigner, you can forcibly decide whether or not to use tweakedSigner. It has a higher priority than disableTweakSigner.

Promise returns SignedPsbtBase64 = string

The signed PSBT base64 string.

Example

await nintondo.multiPsbtSign([
  {
    psbtHex: ["70736274ff01007d...", "70736274ff01007d..."],
    options: [
      {
        autoFinalized: true,
        toSignInputs: [
          {
            index: 0,
            address: "bc1qexampleaddress...",
            sighashTypes: [1, 2],
            useTweakedSigner: false,
          },
        ],
      },
    ],
  },
]);


getNetworkCopied!

nintondo.getNetwork() => Promise<string>

To get the currently selected network of the Nintondo wallet.

Parameters

Returns

none

Promise returns NetworkType = string

The Network from belcoinjs-lib

Example

await nintondo.getNetwork();

> 'testnet'


switchNetworkCopied!

nintondo.switchNetwork(network: NetworkType) => Promise<string>

To switch the network of the Nintondo wallet.

Parameters

Returns

network - string ; The network to switch to.

Promise returns NetworkType: string

network - The network to switch to.

Example

await nintondo.switchNetwork("mainnet");

> 'mainnet'


EventsCopied!

accountsChangedCopied!

nintondo.on('accountsChanged', () => void);
nintondo.removeListener('accountsChanged', () => void);
nintondo.removeAllListeners('accountsChanged')

The accountsChanged will be emitted whenever the user's exposed account address changes.


networkChangedCopied!

nintondo.on('networkChanged', (network: NetworkType) => void);
nintondo.removeListener('networkChanged', (network: NetworkType) => void);
nintondo.removeAllListeners('networkChanged')

The networkChanged will be emitted whenever the user's network changes.