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
To ensure optimal functionality, your code editor and project must use the same TypeScript version.
TypeScript Version: Ensure you have TypeScript version 5.0.2 or higher installed.
TS Config Setup:
Set the compilerOptions.moduleResolution to bundler.
This setup will help maintain consistency and leverage TypeScript's latest features efficiently.
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
Import the SDK
import DOSafeSDK from "@dos.me/wallet-sdk";
Initialize the SDK
Create a new instance of the DOSafe SDK with your configuration parameters:
The following methods are available on the SDK instance:
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
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 .
Initiates the wallet authentication process.
Open wallet popup
Manually opens the wallet popup interface.
Logout
Disconnects from the wallet and clears the session.
Read from contract
Reads data from a smart contract.
Write to contract
Executes a transaction on a smart contract.
TypeScript support
For TypeScript projects, create a declaration file named dosafe-sdk.d.ts with the following type definitions:
Troubleshooting
Tip: Ensure the
chainDefaultvalue is part of thechainsSupportedarray.
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
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",
};