Kadena dApp Integration
CLV extension wallet will inject clover_kadena to window object, dApp could use it to integrate with CLV extension wallet.
1
window.clover_kadena = {
2
isCloverWallet: true,
3
getAccount: async ()=> {...},
4
sign: async (paload) => {...}
5
}
Copied!

Sample Code

Below is an example for dApp to integrate CLV extension wallet
1
signKdaTransaction = async () => {
2
if (!window.clover_kadena) {
3
this.console('wallet not injected!')
4
}
5
​
6
var mkReq = function(cmd) {
7
return {
8
headers: {
9
"Content-Type": "application/json"
10
},
11
method: "POST",
12
body: JSON.stringify(cmd)
13
};
14
};
15
​
16
try {
17
const account = await window.clover_kadena.getAccount()
18
await new Promise((resolve) => setTimeout(resolve, 3000))
19
const signCmd = {
20
pactCode: `(free.hello-world.set-message ${JSON.stringify('hello test')})`,
21
caps: [
22
Pact.lang.mkCap("Gas capability", "description of gas cap", "coin.GAS", []).cap,
23
],
24
sender: account,
25
gasLimit: 10000,
26
chainId: "0",
27
ttl: 28800,
28
envData: {}
29
}
30
​
31
const result = await window.clover_kadena.sign(signCmd)
32
const txRes = await fetch(`https://api.testnet.chainweb.com/chainweb/0.0/testnet04/chain/0/pact/api/v1/send`, mkReq(result));
33
const tx = await txRes.json();
34
} catch (e) {
35
console.log(e)
36
}
37
}
Copied!
Copy link
Contents
Sample Code