Provider
Nintondo Wallet API
This documentation is here to help you learn how to create applications for the Nintondo Wallet.
Getting Started
Installation
npm i nintondo-sdkUsage (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>
  );
};Methods
connect
nintondo.provider.connect(networkType?: NetworkType) => Promise<string>To connect to the Nintondo provider.
| Parameters | Returns | 
|---|---|
| 
 | 
 The address of the connected account. | 
Example
await nintondo.connect("bellsMainnet");
> 'tbel1qxdp6v2u0q0tthc67e8sz2t3udykz99yrmnmvc5'getBalance
nintondo.provider.getBalance() => Promise<number>The get balance of the connected account.
| Parameters | Returns | 
|---|---|
| none | 
 The balance of the connected account. | 
Example
await nintondo.getBalance();
> 38285545404138getAccountName
nintondo.provider.getAccountName() => Promise<string>To get the current account name from the Nintondo provider.
| Parameters | Returns | 
|---|---|
| none | 
 The name of the connected account. | 
Example
await nintondo.getAccountName();
> 'Account 1'isConnected
nintondo.provider.isConnected() => Promise<boolean>To get the connection state from the Nintondo provider.
| Parameters | Returns | 
|---|---|
| none | 
 The connection state. | 
Example
await nintondo.isConnected();
> truegetAccount
nintondo.provider.getAccount() => Promise<string>To get the current account from the Nintondo provider.
| Parameters | Returns | 
|---|---|
| none | 
 The address of the connected account. | 
Example
await nintondo.getAccount();
> 'tbel1qxdp6v2u0q0tthc67e8sz2t3udykz99yrmnmvc5'getPublicKey
nintondo.provider.getPublicKey() => Promise<string>To get the public key of the connected account from the Nintondo provider.
| Parameters | Returns | 
|---|---|
| none | 
 The public key of the connected account. | 
Example
await nintondo.getPublicKey();
> '02e2eac63c70b030f7ed7d1b37a3v56002dcc986e43c35c704532cf913e9dbh098'getVersion
nintondo.provider.getVersion() => Promise<string>To get the version of the Nintondo provider.
| Parameters | Returns | 
|---|---|
| none | 
 The version of the Nintondo provider in the format x.x.x. | 
Example
await nintondo.getVersion();
> '0.3.4'createTx
nintondo.provider.createTx(payload: CreateTxPayload) => Promise<string>To create a transaction.
| Parameters | Returns | 
|---|---|
| 
 
 
 
 | 
 The signed transaction hex. | 
Example
await nintondo.createTx({
    to: "EMpxzi7FujHsQHbrZy7wsuiRHFsvxKZSaB",
    amount: 10_000_000,
    receiverToPayFee: true,
    feeRate: 10
});
> '01000000058661950a3f261f4bbded75684...'signMessage
nintondo.provider.signMessage(message: string) => Promise<string>To sign a message.
| Parameters | Returns | 
|---|---|
| 
 | 
 The signature message. | 
Example
await nintondo.signMessage("nintondo");
> 'UoQCs9wqDTsyt/3dinivJCO37fuKfqJSVyzNMSS8BrARECNLDf04Od5si0dsJ1RuE8JT/lDWnaJZRcV9WPMkyA=='calculateFee
nintondo.provider.calculateFee(psbtHex: SignedPsbtBase64, feeRate: number) 
=> Promise<number>To calculate the fee of a transaction.
| Parameters | Returns | 
|---|---|
| 
 | 
 The fee of the transaction. | 
Example
await nintondo.calculateFee("xxxxxxxx", 54)
> 5454signPsbt
nintondo.providersignPsbt(
    psbtBase64: string,
    options?: SignPsbtOptions) => Promise<string>To sign a PSBT.
| Parameters | Returns | 
|---|---|
| 
 
 | 
 The signed PSBT base64 string. | 
Example
await nintondo.signPsbt("xxxxxxxx",{toSignInputs:[
{index:0,publicKey:"xxxxxx",disableTweakSigner:true}]})multiPsbtSign
nintondo.provider.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 | 
|---|---|
| 
 
 
 | 
 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,
          },
        ],
      },
    ],
  },
]);getNetwork
nintondo.provider.getNetwork() => Promise<string>To get the currently selected network of the Nintondo wallet.
| Parameters | Returns | 
|---|---|
| none | 
 The Network from belcoinjs-lib | 
Example
await nintondo.getNetwork();
> 'testnet'disconnect
nintondo.provider.disconnect() => Promise<void>To disconnect connected account
| Parameters | Returns | 
|---|---|
| none | none | 
Example
await nintondo.disconnect();  
> undefinedEvents
accountsChanged
nintondo.provider.on('accountsChanged', () => void);
nintondo.provider.removeListener('accountsChanged', () => void);
nintondo.provider.removeAllListeners('accountsChanged')The accountsChanged will be emitted whenever the user's exposed account address changes.
disconnected
nintondo.provider.on('disconnected', () => void);
nintondo.provider.removeListener('disconnected', () => void);
nintondo.provider.removeAllListeners('disconnected')The disconnected will be emitted whenever the user's network changes.