# Ethereum Coin98 Telegram Wallet SDK Bot Integration For React

Welcome to Coin98 Telegram Wallet Developer Guide.

This documentation guides developers building on the Coin98 Telegram Wallet using **ReactJS.** Any methods not listed here aren’t supported at the moment.

**Outline**

* [Initialize SDK](#ethereumsuperwalletsdkbotintegrationforreact-initializesdk)
* [Experience functions](#ethereumsuperwalletsdkbotintegrationforreact-experiencefunctions)
  * [1. Transfer](#ethereumsuperwalletsdkbotintegrationforreact-1.transfer)
  * [2. Decrypt](#ethereumsuperwalletsdkbotintegrationforreact-2.decrypt)
  * [3. Get Encryption Public Key](#ethereumsuperwalletsdkbotintegrationforreact-3.getencryptionpublickey)
  * [4. Encrypt](#ethereumsuperwalletsdkbotintegrationforreact-4.encrypt)
  * [5. Switch Ethereum Chain](#ethereumsuperwalletsdkbotintegrationforreact-5.switchethereumchain)
  * [6. Sign Typed Data](#ethereumsuperwalletsdkbotintegrationforreact-6.signtypeddata)
  * [7. Sign Typed Data V3](#ethereumsuperwalletsdkbotintegrationforreact-7.signtypeddatav3)
  * [8. Sign Typed Data V4](#ethereumsuperwalletsdkbotintegrationforreact-8.signtypeddatav4)
  * [9. Personal Sign](#ethereumsuperwalletsdkbotintegrationforreact-9.personalsign)

## Initialize SDK <a href="#ethereumsuperwalletsdkbotintegrationforreact-initializesdk" id="ethereumsuperwalletsdkbotintegrationforreact-initializesdk"></a>

```
import { Coin98Provider } from '@coin98-com/telegram-connect-sdk'
<Coin98Provider chainId={chainId} partner={partner}>
	{children}
</Coin98Provider>
```

**Explain:**

* chainId: specific chain id evm
* partner: specific partner to know which is connecting

**To connect Coin98 Telegram Wallet**

To connect to Coin98 Telegram Wallet means to access the user's \[blockchain - like Ethereum] account(s).

```
import { useEvmHv andle } from '@coin98-com/telegram-connect-sdk'

const { connect } = useEvmHandle()
await connect()
```

## Experience functions <a href="#ethereumsuperwalletsdkbotintegrationforreact-experiencefunctions" id="ethereumsuperwalletsdkbotintegrationforreact-experiencefunctions"></a>

Once your account is connected, let's start experiencing more functions.‌

#### 1. Transfer <a href="#ethereumsuperwalletsdkbotintegrationforreact-1.transfer" id="ethereumsuperwalletsdkbotintegrationforreact-1.transfer"></a>

return `Promise<hash>` - Initiates a new transaction.

```
import { useEvmHandle } from '@coin98-com/telegram-connect-sdk'
const {sendTransaction, address} = useEvmHandle()

const handleSendTransaction = async () => {
	await sendTransaction({
		from: address,
		to: {{TO_ADDRESS}},
		value: '0x0'
	})
}
```

#### 2. Decrypt <a href="#ethereumsuperwalletsdkbotintegrationforreact-2.decrypt" id="ethereumsuperwalletsdkbotintegrationforreact-2.decrypt"></a>

return `Promise<string>` - Decrypts an encrypted message.

```
import { useEvmHandle } from '@coin98-com/telegram-connect-sdk'
const {decryptKey} =  useEvmHandle()
await  decryptKey(<DATA_ENCRYPT>)
```

#### 3. Get Encryption Public Key <a href="#ethereumsuperwalletsdkbotintegrationforreact-3.getencryptionpublickey" id="ethereumsuperwalletsdkbotintegrationforreact-3.getencryptionpublickey"></a>

return `Promise<string>`- The public encryption key of the Ethereum account whose encryption key should be retrieved

```
import { useEvmHandle } from '@coin98-com/telegram-connect-sdk'
const { getEncryptionKey } = useEvmHandle()
await getEncryptionKey()
```

#### 4. Encrypt <a href="#ethereumsuperwalletsdkbotintegrationforreact-4.encrypt" id="ethereumsuperwalletsdkbotintegrationforreact-4.encrypt"></a>

return `Promise<string>` - Encrypt message.

```
import { useEvmHandle } from '@coin98-com/telegram-connect-sdk'
const { encryptKey } =  useEvmHandle()
encryptKey(value);
```

#### 5. Switch Ethereum Chain <a href="#ethereumsuperwalletsdkbotintegrationforreact-5.switchethereumchain" id="ethereumsuperwalletsdkbotintegrationforreact-5.switchethereumchain"></a>

* In our current flow, simply change the `chainId` in parameters before using any method.
* Our Coin98 Telegram Wallet Bot will automatically detect and switch chains accordingly

#### 6. Sign Typed Data <a href="#ethereumsuperwalletsdkbotintegrationforreact-6.signtypeddata" id="ethereumsuperwalletsdkbotintegrationforreact-6.signtypeddata"></a>

return `Promise<string>` - Presents a structured data message for the user to sign.

```
import { useEvmHandle } from '@coin98-com/telegram-connect-sdk'
const { signTypedData, address } = useEvmHandle()

const handleSignPersonal = () => {
	signTypedData([
		{
			"type": "string",
			"name": "Message",
			"value": "Hi, Alice!"
		},
		{
			"type": "uint32",
			"name": "A number",
			"value": "1337"
		}
	])
}
```

#### 7. Sign Typed Data V3 <a href="#ethereumsuperwalletsdkbotintegrationforreact-7.signtypeddatav3" id="ethereumsuperwalletsdkbotintegrationforreact-7.signtypeddatav3"></a>

return `Promise<string>` - Presents a structured data message for the user to sign.

```
import { useEvmHandle } from '@coin98-com/telegram-connect-sdk'
const { signTypedDataV3, address, chainId } = useEvmHandle()

const handleSignPersonal = () => {
	signTypedDataV3({
		types: {
			EIP712Domain: [
				{ name: "name", type: "string" },
				{ name: "version", type: "string" },
				{ name: "chainId", type: "uint256" },
				{ name: "verifyingContract", type: "address" },
			],
			Person: [
				{ name: 'name', type: 'string' },
				{ name: 'wallet', type: 'address' },
			],
			Mail: [
				{ name: 'from', type: 'Person' },
				{ name: 'to', type: 'Person' },
				{ name: 'contents', type: 'string' },
			],
		},
		primaryType: 'Mail',
		domain: {
		name: 'Ether Mail',
		version: '1',
		chainId: Number(chainId),
		verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
		},
		message: {
			from: {
				name: 'Cow',
				wallet: <FROM ADDRESS>,
			},
			to: {
				name: 'Bob',
				wallet: <TO ADDRESS>,
			},
			contents: 'Hello, Bob!',
		},
	})
}
```

#### 8. Sign Typed Data V4 <a href="#ethereumsuperwalletsdkbotintegrationforreact-8.signtypeddatav4" id="ethereumsuperwalletsdkbotintegrationforreact-8.signtypeddatav4"></a>

return `Promise<string>` - Presents a structured data message for the user to sign.

```
import { useEvmHandle } from '@coin98-com/telegram-connect-sdk'
const { signTypedDataV4, address, chainId } = useEvmHandle()

const handleSignPersonal = () => {
	signTypedDataV4({
		domain: {
		chainId: Number(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[]' },
			],
		}
	})
}
```

#### 9. Personal Sign <a href="#ethereumsuperwalletsdkbotintegrationforreact-9.personalsign" id="ethereumsuperwalletsdkbotintegrationforreact-9.personalsign"></a>

return `Promise<string>` - Presents a plain text signature challenge to the user.

```
const { personalSign } = useEvmHandle()

const handleSignPersonal = () => {
	personalSign({
		message: 'This is message'
	})
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coin98.com/developer-guide/ethereum-coin98-telegram-wallet-sdk-bot-integration/ethereum-coin98-telegram-wallet-sdk-bot-integration-for-react.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
