All pages
Powered by GitBook
1 of 1

Loading...

Get Started

Developers can follow this guide and configuration sections to launch an ecosystem wallet. Alternatively, if you prefer to use an existing ecosystem wallet SDK, refer to the usage section to install

The DOSwap SDK provides a straightforward method to create your own ecosystem wallet. It offers a code-splitting environment and essential tools to bring your wallet SDK to life, making the process both easy and efficient.

Video

Requirements

To ensure optimal functionality, your code editor and project must use the same TypeScript version.

  1. TypeScript Version: Ensure you have TypeScript version 5.0.2 or higher installed.

  2. TS Config Setup:

    • Set the compilerOptions.moduleResolution to bundler.

This setup will help maintain consistency and leverage TypeScript's latest features efficiently.

Install the DOSafe SDK

In your wallet SDK directory, use your preferred package manager to install the latest Ecosystem SDK version:

npm install @dos.me/wallet-sdk

yarn add @dos.me/wallet-sdk

Creating your wallet SDK

1

Import the SDK

import DOSafeSDK from "@dos.me/wallet-sdk";

2

Initialize the SDK

Create a new instance of the DOSafe SDK with your configuration parameters:

3

SDK methods

The following methods are available on the SDK instance:

1

Check wallet connection

Check if the wallet is currently connected.

2

Enable Code Splitting: Configure your project to support code splitting for enhanced performance.

Configuration parameters

The following table describes the configuration parameters for the DOSafe SDK:

Parameter

Required

Description

appName

Yes

Your application name

appLogoUrl

Yes

URL of your application logo

backendUrl

Yes

DOSafe backend URL for authentication

4

Environment URLs

Backend URL (backendUrl)

Development: https://beta.dos.me

Production: https://api.dos.me

Wallet URLs (walletUrl)

Development: https://test-of-wallet.doschain.com

Production: https://wallet.doschain.com

Token configuration (tokens)

The tokens parameter requires a specific JSON structure:

[!IMPORTANT] To obtain policy IDs and register token/NFT contracts in the DOSafe system, contact DOSafe support at .

Authenticate wallet

Initiates the wallet authentication process.

3

Connect wallet

Establishes a connection to the DOSafe wallet.

4

Open wallet popup

Manually opens the wallet popup interface.

5

Logout

Disconnects from the wallet and clears the session.

6

Read from contract

Reads data from a smart contract.

7

Write to contract

Executes a transaction on a smart contract.

8

TypeScript support

For TypeScript projects, create a declaration file named dosafe-sdk.d.ts with the following type definitions:

9

Troubleshooting

Tip: Ensure the chainDefault value is part of the chainsSupported array.

Note: Register ERC-20 token contracts and NFT contracts in the DOSafe system before

const connectResult = await walletSDK.connectWalletDOS();
await walletSDK.openPopupWallet();
await walletSDK.logout();
const data = await walletSDK.readContract(
  "0xContractAddress",  // Contract address
  contractABI,          // Contract ABI as array
  "functionName",       // Function to call
  [param1, param2]      // Function arguments
);
const txResult = await walletSDK.writeContract(
  contractAddress,  // Contract address
  contractABI,          // Contract ABI as array
  functionName,       // Function to call
  [param1, param2]      // Function arguments
);
declare module "@dos/wallet-sdk" {
  class DOSafeSDK {
    constructor(config: {
      appName: string;
      appLogoUrl: string;
      backendUrl: string;
      walletUrl: string;
      ecosystemId: string;
      tokens: any;
      contractNFTs: any;
      policies: any;
      webPublicKey: string;
      chainsSupported: number[];
      typeSDK: string;
      chainDefault: number;
    });
    checkWalletDOS(): Promise<any>;
    authenticateWalletDOS(): Promise<any>;
    connectWalletDOS(): Promise<any>;
    openPopupWallet(): Promise<any>;
    logout(): Promise<any>;
    readContract(
      contractAddress: string,
      abiContract: any,
      functionName: string,
      args: any[]
    ): Promise<any>;
    writeContract(
      contractAddress: string,
      abiContract: any,
      functionName: string,
      args: any[]
    ): Promise<any>;
  }
  export default DOSafeSDK;
}
const walletSDK = new DOSafeSDK({
  appName: "Your App Name",
  appLogoUrl: "Your App Logo URL",
  backendUrl: " Our Authentication Endpoint", // Backend URL
  walletUrl: " Our Wallet Endpoint", // Production URL
  ecosystemId: "Your Ecosystem ID",
  tokens: tokens,
  contractNFTs: contractNFTs,
  chainsSupported: [43113, 3939],
  policies: policyConfigurations,
  webPublicKey: "Your_Web_Public_Key",
  typeSDK: "popup", // 'sdk' or 'popup'
  explorerUrl: "https://testnet.snowtrace.io",
  chainDefault: 43113,
});
const connectionStatus = await walletSDK.checkWalletDOS();
const authResult = await walletSDK.authenticateWalletDOS();

walletUrl

Yes

DOSafe wallet URL for transactions

ecosystemId

Yes

Your ecosystem ID provided by DOSafe

tokens

Yes

Token configuration by chain

contractNFTs

Yes

List of NFT contracts

chainsSupported

Yes

Array of supported chainIds

policies

Yes

Object containing policy IDs by chainId

webPublicKey

Yes

Your web public key for verification

typeSDK

Yes

SDK type ('sdk' or 'popup')

explorerUrl

No

Blockchain explorer URL

chainDefault

Yes

Default chainId to display first

[email protected]
const tokenConfigurations = {
  "43113": { // Avalanche Fuji Testnet
    "AVAX": {
      symbol: "AVAX",
      decimals: 18,
      contract: "", // Empty for native tokens
      provider: "https://avalanche-fuji-c-chain-rpc.publicnode.com",
      type: "native",
      abi: [],
    },
    "SECOND": {
      symbol: "SECOND",
      decimals: 18,
      contract: "0x10627F7D8117c4BdB9409813b47da5B21CAB5F9b",
      provider: "https://avalanche-fuji-c-chain-rpc.publicnode.com",
      type: "erc20",
      abi: [],
    },
  },
  "3939": { // DOS Chain Testnet
    "DOS": {
      symbol: "DOS",
      decimals: 18,
      contract: "",
      provider: "https://test.doschain.com",
      type: "native",
      abi: [],
    },
    "SECOND": {
      symbol: "SECOND",
      decimals: 18,
      contract: "0x17a11Dd7095555E26275F2DE38Ba4548229f5bbc",
      provider: "https://test.doschain.com",
      type: "erc20",
      abi: [],
    },
  }
};
NFT configuration (contractNFTs)
The contractNFTs parameter accepts an array of objects:
const nftConfigurations = [
  {
    chainId: 43113,
    contract: "0x7979c2815CD58184Bd91082CDe5E001f18b22368",
    abi: [],
  },
  {
    chainId: 3939,
    contract: "0x5f33e2db1448933f8e3B5a630E01D8E357bFe62F",
    abi: [],
  }
];
Policy configuration (policies)
The policies parameter requires an object mapping chain IDs to policy identifiers:
const policyConfigurations = {
  "43113": "pol_avalanche_policy_id",
  "3939": "pol_dos_chain_policy_id",
};