@dos.me/wallet-sdk
v1.0.5
Published
DOSafe SDK is a JavaScript library that allows you to integrate the DOSafe wallet into your web application. This SDK supports interaction with different blockchains and provides features such as token management, NFTs, and security policies.
Readme
DOSafe SDK
Introduction
DOSafe SDK is a JavaScript library that allows you to integrate the DOSafe wallet into your web application. This SDK supports interaction with different blockchains and provides features such as token management, NFTs, and security policies.
Installation
npm install @dos.me/wallet-sdkor
yarn add @dos.me/wallet-sdkBasic Usage
Import SDK
import DOSafeSDK from "@dos.me/wallet-sdk";Initialize SDK
const walletSDK = new DOSafeSDK({
appName: "Your App Name",
appLogoUrl: "Your App Logo URL",
backendUrl: "Our Authentication Endpoint",
walletUrl: "Our Wallet Endpoint",
ecosystemId: "Your Ecosystem ID",
tokens: "Token Configs",
contractNFTs: "NFT Configs",
chainsSupported: "Chains Support",
policies: "Policies Support",
webPublicKey: "Your_Web_Public_Key",
typeSDK: "extension", // 'sdk', 'popup', or 'extension'
windowStrategy: "iframe", // Optional - defines how the wallet window is displayed
explorerUrl: "https://testnet.snowtrace.io",
chainDefault: 43113,
});Configuration Parameters
| Parameter | Description | |-----------|-------------| | appName | Your application name | | appLogoUrl | URL of your application logo | | backendUrl | DOSafe backend URL | | walletUrl | DOSafe wallet URL | | ecosystemId | Your ecosystem ID | | tokens | Token configuration by chain | | contractNFTs | List of NFT contracts | | chainsSupported | Array of supported chainIds | | policies | Object containing policy IDs by chainId | | webPublicKey | Your web public key | | typeSDK | SDK type ('sdk', 'popup', or 'extension') | | windowStrategy | How the wallet window is displayed (e.g., 'iframe') | | explorerUrl | Blockchain explorer URL | | chainDefault | Default chainId |
Detailed Parameter Information
backendUrl
The endpoint for authentication with two available environments:
- Development: https://beta.dos.me
- Production: https://api.dos.me
walletUrl
Website designed for transaction execution with two available environments:
- Development: https://test-of-wallet.doschain.com
- Production: https://wallet.doschain.com
ecosystemId
A unique identifier generated from our ecosystem. Contact support to obtain this information.
tokens
Configuration for coins supported in your wallet. Must be formatted as JSON according to the following standard:
{
"43113": {
"AVAX": {
"symbol": "AVAX",
"decimals": 18,
"contract": "",
"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": {
"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": []
}
}
}contractNFTs
Configuration for NFT addresses supported in your wallet. Must be formatted as an array of objects according to the following standard:
[
{
"chainId": 43113,
"contract": "0x7979c2815CD58184Bd91082CDe5E001f18b22368",
"abi": []
},
{
"chainId": 3939,
"contract": "0x5f33e2db1448933f8e3B5a630E01D8E357bFe62F",
"abi": []
}
]policies
Chain-specific policy IDs. Contact support to obtain this information.
{
"43113": "pol_072eec75-b3db-4d0f-a286-8bf2fd5d8c59",
"3939": "pol_fae6f004-ff5b-41ee-8c7f-bcf7e52553c2"
}typeSDK
A string defining the type of SDK display. Three options available:
"sdk": Displays wallet popup when needed"popup": Always displays wallet popup"extension": For browser extension integration
windowStrategy
Defines how the wallet window is displayed:
"iframe": Displays the wallet in an iframe within your application
chainDefault
The Chain ID that will be displayed first when opening the popup. Must be included in chainsSupported.
Important Note: ERC20 token contracts and NFT contracts must be added to our system before use. Please contact support for assistance with this process.
Available SDK Methods
| Method | Description | Parameters |
|--------|-------------|------------|
| checkWalletDOS() | Checks if the wallet is connected | None |
| authenticateWalletDOS() | Authenticates the wallet | None |
| connectWalletDOS() | Connects to the wallet | None |
| openPopupWallet() | Opens the wallet in a popup | None |
| logout() | Disconnects from the wallet | None |
| readContract() | Reads data from a smart contract | contractAddress, abiContract, functionName, args |
| writeContract() | Writes data to a smart contract | contractAddress, abiContract, functionName, args |
TypeScript Support
For TypeScript users, you need to add a declaration file to define the types for the SDK. Create a file named dosafe-sdk.d.ts in your project with the following content:
declare module "@dos.me/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;
windowStrategy?: string;
explorerUrl: string;
chainDefault: number;
});
checkWalletDOS(): Promise<any>;
authenticateWalletDOS(): Promise<any>;
connectWalletDOS(): Promise<any>;
openPopupWallet(): Promise<any>;
logout(): Promise<any>;
triggerEvent(eventName: string, eventData: any): void;
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;
}This will provide type definitions for the SDK when using TypeScript in your project.
Support
If you encounter any issues or have questions, please contact us at [email protected].
License
MIT
