Build with COTI Wallet

Integrate COTI Wallet into your application using our SDK to handle payments, transactions, and wallet interactions directly in your product.

Easy Integration
Clear documentation
Open-source tools

Getting Started

Everything you need to start building with Coti Wallet SDK

1. Install SDK

Download and install Coti Wallet SDK for your platform. Available for Windows, macOS, and Linux.

2. Initialize

Initialize the SDK with your API credentials and configure connection parameters.

3. Start Building

Use our APIs to connect wallets, sign transactions, and interact with blockchain networks.

Installation

Install Coti Wallet SDK on your preferred platform

Windows

Install the SDK using npm in your development environment:

bash
npm install @coti-wallet/sdk

System Requirements:

  • Windows 10 or later (64-bit)
  • Node.js 16.x or later
  • 4GB RAM minimum

macOS

Install via npm or Homebrew:

bash
brew install coti-wallet-sdk

System Requirements:

  • macOS 11 Big Sur or later
  • Node.js 16.x or later
  • 4GB RAM minimum

Linux

Install via npm or your package manager:

bash
sudo apt-get install coti-wallet-sdk

System Requirements:

  • Ubuntu 20.04+ / Debian 10+ / Fedora 35+
  • Node.js 16.x or later
  • 4GB RAM minimum

Quick Start Guide

Start integrating COTI Wallet in your application

01

Import SDK

Import and initialize the COTI Wallet SDK:

javascript
import { CotiWallet } from '@coti-wallet/sdk';

const wallet = new CotiWallet();

await wallet.initialize();
02

Connect Wallet

Connect to the user's wallet:

javascript
const connectWallet = async () => {
  try {
    await wallet.connect();
    console.log('Wallet connected');
  } catch (error) {
    console.error('Connection failed:', error);
  }
};
03

Get Balance

Retrieve the current wallet balance:

javascript
const getBalance = async () => {
  try {
    const balance = await wallet.getBalance();
    console.log('Balance:', balance);
    return balance;
  } catch (error) {
    console.error('Failed to get balance:', error);
  }
};
04

Send Transaction

Send a transaction from the wallet:

javascript
const sendTransaction = async (to, amount) => {
  try {
    const tx = await wallet.sendTransaction({
      to,
      amount
    });
    console.log('Transaction sent:', tx);
    return tx;
  } catch (error) {
    console.error('Transaction failed:', error);
  }
};

API Reference

Complete reference for Coti Wallet SDK methods

wallet.connect()

Promise<string[]>

Requests connection to user's Coti Wallet and returns an array of wallet addresses.

Parameters

None

Example

const accounts = await wallet.connect();

wallet.getBalance(address)

Promise<string>

Returns the balance of the specified wallet address in wei.

Parameters

  • address (string) - Wallet address to check

Example

const balance = await wallet.getBalance('0x742d35...');

wallet.sendTransaction(params)

Promise<Transaction>

Sends a transaction to the blockchain network.

Parameters

  • params.to (string) - Recipient address
  • params.value (string) - Amount to send in wei
  • params.gas (number) - Gas limit for transaction
  • params.data (string, optional) - Transaction data

Example

const tx = await wallet.sendTransaction({
  to: '0x742d35...',
  value: '1000000000000000000',
  gas: 21000
});

wallet.signMessage(message)

Promise<string>

Signs a message with the user's private key.

Parameters

  • message (string) - Message to sign

Example

const signature = await wallet.signMessage('Hello World');

wallet.switchNetwork(chainId)

Promise<void>

Switches to a different blockchain network.

Parameters

  • chainId (number) - Chain ID of target network

Example

await wallet.switchNetwork(1); // Ethereum Mainnet

wallet.disconnect()

Promise<void>

Disconnects the wallet from your application.

Parameters

None

Example

await wallet.disconnect();

Complete Examples

Ready-to-use code examples for common use cases

Simple Wallet Integration

JavaScript React
javascript
import React, { useState, useEffect } from 'react';
import { CotiWallet } from '@coti-wallet/sdk';

function App() {
  const [wallet, setWallet] = useState(null);
  const [account, setAccount] = useState(null);

  useEffect(() => {
    const initWallet = async () => {
      const instance = new CotiWallet();
      await instance.initialize();
      setWallet(instance);
    };

    initWallet();
  }, []);

  const connect = async () => {
    try {
      const address = await wallet.connect();
      setAccount(address);
    } catch (error) {
      console.error('Connection failed:', error);
    }
  };

  return (
    <div>
      {account ? (
        <p>Connected: {account}</p>
      ) : (
        <button onClick={connect}>
          Connect Wallet
        </button>
      )}
    </div>
  );
}

export default App;

Token Transfer

JavaScript Web3
javascript
import { CotiWallet } from '@coti-wallet/sdk';

async function transferTokens(recipient, amount) {
  try {
    const wallet = new CotiWallet();
    await wallet.initialize();

    await wallet.connect();

    const tx = await wallet.sendTransaction({
      to: recipient,
      amount: amount
    });

    console.log('Transaction sent:', tx);

    return tx;
  } catch (error) {
    console.error('Transfer failed:', error);
    throw error;
  }
}

Message Signing

JavaScript Authentication
javascript
import { CotiWallet } from '@coti-wallet/sdk';

async function authenticateUser() {
  try {
    const wallet = new CotiWallet();
    await wallet.initialize();

    const address = await wallet.connect();

    const message = `Sign this message to authenticate:
Address: ${address}
Timestamp: ${Date.now()}`;

    const signature = await wallet.signMessage(message);

    const response = await fetch('/api/auth', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        address,
        message,
        signature
      })
    });

    const data = await response.json();
    return data.token;
  } catch (error) {
    console.error('Authentication failed:', error);
    throw error;
  }
}

Ready to Start Building?

Download Coti Wallet and start building secure blockchain applications today