Skip to main content

🧩 UXUY Connect Guide

Overview

This guide demonstrates how to integrate the UXUY Wallet into your telegram mini application (miniapp) using the UXUY Connect SDK.

The integration enables users to connect their UXUY Wallet on Telegram and perform multi-chain transactions seamlessly.

Resources

Installation

Install the UXUY SDK using npm:

npm install @uxuycom/web3-tg-sdk

Usage

Importing the SDK

import { WalletTgSdk } from '@uxuycom/web3-tg-sdk';

const { ethereum } = new WalletTgSdk({
metaData: {
name: 'Your DApp Name',
icon: 'https://example.com/icon.png'
}
});

Ethereum Provider API

The UXUY SDK implements the Ethereum Provider API, allowing seamless integration with existing Ethereum-compatible DApps.

isConnected

The isConnected method returns a boolean value indicating whether the wallet is connected or not.


ethereum.isConnected(): boolean

Request Method

The request method is used to make RPC requests to the connected wallet.

interface RequestArguments {
id?: number | string;
method: string;
params?: Array<unknown> ;
}

interface ResponseError extends Error {
code: number;
message: string;
data?: unknown;
}

ethereum.request = (payload: RequestArguments): Promise<any>

For detailed information on JSON-RPC methods, refer to:

Supported Methods

eth_requestAccounts

Connects to the wallet and returns the address of the connected wallet.

const accounts = await ethereum.request({ method: 'eth_requestAccounts' });

eth_accounts

Returns the address of the connected wallet.

const accounts = await ethereum.request({ method: 'eth_accounts' });

eth_chainId

Returns the chainId of the connected wallet.

const chainId = await ethereum.request({ method: 'eth_chainId' });

wallet_switchEthereumChain

Switches the connected wallet to the specified chainId.

try {
await ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: '0xf00' }],
});
} catch (switchError) {
// Handle the error
}

eth_sendTransaction

Sends a transaction to the connected wallet.

For detailed usage, refer to:


const accounts = await ethereum.request({ method: 'eth_accounts' });
const transactionParameters = {
nonce: '0x00',
gasPrice: '0x09184e72a000',
gas: '0x2710',
to: '0x0000000000000000000000000000000000000000',
from: accounts[0],
value: '0x00',
data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',
chainId: '0x3',
};

const txHash = await ethereum.request({
method: 'eth_sendTransaction',
params: [transactionParameters]
});

Signing Methods

The UXUY SDK supports various signing methods:

  • personal_sign
  • eth_signTypedData
  • eth_signTypedData_v3
  • eth_signTypedData_v4

For detailed usage, refer to:

Example of personal_sign:

const  accounts = await ethereum.request({ method: 'eth_accounts' });
const chainId = await ethereum.request({ method: 'eth_chainId' });

const signature = await ethereum.request({
method: 'personal_sign',
params: ['Hello, UXUY!', accounts[0]]
});

Example of eth_signTypedData_v4:


const accounts = await ethereum.request({ method: 'eth_accounts' });
const chainId = await ethereum.request({ method: 'eth_chainId' });

const msgParams = {
"domain": {
"chainId": chainId,
"name": "Ether Mail",
"verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
"version": "1"
},
"message": {
"contents": "Hello, Bob!",
"from": {
"name": "Cow",
"wallets": [
"0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826",
"0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF"
]
},
"to": [
{
"name": "Bob",
"wallets": [
"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB",
"0xB0BdaBea57B0BDABeA57b0bdABEA57b0BDabEa57",
"0xB0B0b0b0b0b0B000000000000000000000000000"
]
}
],
"attachment": "0x"
},
"primaryType": "Mail",
"types": {
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"Group": [
{
"name": "name",
"type": "string"
},
{
"name": "members",
"type": "Person[]"
}
],
"Mail": [
{
"name": "from",
"type": "Person"
},
{
"name": "to",
"type": "Person[]"
},
{
"name": "contents",
"type": "string"
},
{
"name": "attachment",
"type": "bytes"
}
],
"Person": [
{
"name": "name",
"type": "string"
},
{
"name": "wallets",
"type": "address[]"
}
]
}
}

const signatureV4 = await ethereum.request({
method: 'eth_signTypedData_v4',
params: [
accounts[0],
JSON.stringify(msgParams)
]
});

Event Listeners

The SDK emits events for account and network changes.

accountsChanged

ethereum.on('accountsChanged', (accounts) => {
console.log('Active account:', accounts[0]);
});

chainChanged

ethereum.on('chainChanged', (chainId) => {
console.log('Network changed to:', chainId);
});

To remove listeners:

ethereum.removeListener('accountsChanged', handleAccountsChanged);
// or remove all listeners
ethereum.removeAllListeners();

Supported Chains

UXUY Wallet supports multiple chains:

Chain NameChain ID (Decimal)Chain ID (Hexadecimal)
Ethereum10x1
BNB Chain560x38
Base84530x2105
Arbitrum421610xa4b1
Polygon1370x89
Fantom2500xfa
Optimism100xa
Avalanche431140xa86a
zkSync Era3240x144
Linea591440xe708
Core11160x45c
zkLink8101800xc5cc4

Contributing

We welcome contributions to the UXUY SDK! Please see our Contributing Guidelines for more information.

License

This project is licensed under the MIT License.