mina_addChain

This method is used to add a custom chain to Auro Wallet.

if you want to switch by URL , you can use this method . if URL is added to wallet , will call switch_chain auto.

Params

type AddChainArgs = {
    // the GraphQL URL that need add.
    readonly url: string
    // custom name.
    readonly name: string
}

Result

type ChainInfoArgs ={
    // current networkID, now will return mina:mainnet, mina:testnet, mina:berkeley
    networkID:string,
}

interface ProviderError extends Error {
    message: string; // error message.
    code: number; // error code.
    data?: unknown; // error body. 
}

Promise<ChainInfoArgs | ProviderError>
** Please update as soon as possible. **
`ChainInfoArgs` params have updated from App 2.0.2 & extension 2.2.17.
Only `networkID` is returned, no longer supports returning `chainId` and `name`. 

// @deprecated from App 2.0.2 & extension 2.2.17.
type ChainInfoArgs ={ 
    chainId:string,
    name:string
}

Errors

Example

Request

const addInfo = {
    url: encodeURIComponent("GraphQL URL"),
    name: "networkName",
}

await window.mina?.addChain(addInfo).catch((err: any) => err);

Result

// successful result.
{
  "networkID": "mina:mainnet"
}

// user reject.
{
  "code": 1002,
  "message": "User rejected the request. "
}

// params check error. there check GraphQL URL.
{
  "code": 20003,
  "message": "Invalid method parameter(s). "
}

// have pending chain action.
{
  "code": 20005,
  "message": "Request already pending. Please wait. "
}

Last updated