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