Web Apps
Estimated time to read: 2 minutes
Integrate with the Arcana CA SDK. Enable unified-balance in 'Web' apps. Let the app users spend anywhere with chain abstracted transactions.
1. Install
npm install --save @arcana/ca-sdk
2. Integrate
import { CA } from '@arcana/ca-sdk'
const provider = window.ethereum
const ca = new CA();
//Set the EVM provider
ca.setEVMProvider(provider);
try {
await ca.init()
} catch (e) {
// Handle exception case
}
ca.init()
Use await
until the init()
call is complete. Then call
any other CA
method listed in the
Arcana CA SDK Reference.
3. Unified Balance
Get chain abstracted unified balance in the user's EOA.
//total chain abstracted unified balance across all chains/tokens
const balances = await ca.getUnifiedBalances();
//total balance for a specific token across all chains
const usdtBalance = await ca.getUnifiedBalance("usdt");
4. CA Transaction
Web3 apps use the standard EIP-1193 provider to issue request
call for transactions. To chain abstract these transactions,
use getEVMProviderWithCA
. It returns a CA enabled provider.
Replace the standard provider with the CA enabled one. This
enables chains abstraction for eth_sendTransaction
operations via
request
call.
const providerWithCA = ca.getEVMProviderWithCA();
await providerWithCA.request({
method: "eth_sendTransaction",
params: [
{
to: "0xEa46Fb4b4Dc7755BA29D09Ef2a57C67bab383A2f",
from: "0x7f521A827Ce5e93f0C6D773525c0282a21466f8d",
value: "0x001",
},
],
});
5. Advanced
The SDK also provides functions to:
- View user intents
- Issue chain abstracted
bridge
andtransfer
functions
Finished.
The 'Web' app is all set to let users spend on any chain via unified balance and chain abstracted transactions.
See Also
Arcana CA SDK Quick Links