-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.example.html
97 lines (84 loc) · 3.63 KB
/
index.example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="./vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Browser Tests</title>
</head>
<body>
<button id="connect">Connect MultiChain</button>
<button id="connect-evm">Connect EVM</button>
<button id="connect-solana">Connect Solana</button>
<button id="send-coin">
Send Coin
</button>
<div class="action-result"></div>
<script type="module">
import appKit from './src/Web3Wallets.ts'
import * as Solana from '@multiplechain/solana'
import * as EvmChains from '@multiplechain/evm-chains'
const solanaProvider = new Solana.Provider({
testnet: true
})
const evmProvider = new EvmChains.Provider({
id: 11155111,
hexId: '0xaa36a7',
mainnetId: 1,
rpcUrl: 'https://sepolia.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
wsUrl: 'wss://sepolia.infura.io/ws/v3/9aa3d95b3bc440fa88ea12eaa4456161',
name: 'Ethereum Sepolia Testnet (QR)',
explorerUrl: 'https://sepolia.etherscan.io/',
nativeCurrency: {
symbol: 'ETH',
name: 'Ethereum',
decimals: 18
}
})
const options = {
themeMode: 'light',
projectId: '113d9f5689edd84ff230c2a6d679c80c'
}
let wallet
document.getElementById('connect').addEventListener('click', async () => {
wallet = new Solana.browser.Wallet(appKit)
await wallet.adapter.disconnect()
wallet.connect(options)
.then((provider) => {
console.log('connected', provider)
})
.catch((error) => {
console.error(error)
})
})
document.getElementById('connect-evm').addEventListener('click', async () => {
await EvmChains.browser.adapters.Web3Wallets.disconnect()
EvmChains.browser.adapters.Web3Wallets.connect(evmProvider, options)
.then((provider) => {
console.log('connected', provider)
})
.catch((error) => {
console.error(error)
})
})
document.getElementById('connect-solana').addEventListener('click', async () => {
await Solana.browser.adapters.Web3Wallets.disconnect()
Solana.browser.adapters.Web3Wallets.connect(solanaProvider, options)
.then((provider) => {
console.log('connected', provider)
})
.catch((error) => {
console.error(error)
})
})
const receiver = 'GHVMV3zZscR8V4K5GEgQTUjuV4jEixB9a4QX3KhgvVKy';
document.getElementById('send-coin').addEventListener('click', async () => {
const sender = await wallet.getAddress()
const coin = new Solana.assets.Coin();
const signer = await coin.transfer(sender, receiver, 0.00001)
const result = await wallet.sendTransaction(signer)
document.querySelector('.action-result').innerText = result
})
</script>
</body>
</html>