Provider
A thin JSON-RPC wrapper for interacting with chains and Blocto wallet.
Blocto SDK comes with an Petra (Aptos official wallet) API-compatible provider, you can use it to interact with Aptos network.
Note that Blocto SDK for Aptos is still in Beta. APIs are subject to breaking changes.
Installation
Install from npm/yarn
$ yarn add @blocto/sdk
... or via CDN
<script src="https://unpkg.com/@blocto/sdk" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
Get App ID
It's required to register an app id before using Blocto SDK, check out the Register App ID section
Usage
Initiate the Blocto provider
import BloctoSDK from '@blocto/sdk'
const bloctoSDK = new BloctoSDK({
aptos: {
// (required) chainId to be used
chainId: 1,
},
// (required) Blocto app ID
appId: 'YOUR_BLOCTO_APP_ID',
});
Blocto Provider parameters
aptos.chainId
number
Aptos chain ID to connect to
Yes
appId
String
Blocto dApp ID
Yes
Examples
const bloctoSDK = new BloctoSDK({
aptos: {
chainId: 1,
},
appId: 'YOUR_BLOCTO_APP_ID',
});
Connect to Blocto wallet
Once the connection request is fired, there would be a prompt modal to guide user to register/login to Blocto wallet
const {
address, // address of the connected account
publicKey, // public keys (array) of the multi-sig account
authKey, // authentication key
} = await bloctoSDK.aptos.connect()
After connecting with Blocto wallet, you can start to interact with Aptos blockchain with Blocto provider.
Last updated
Was this helpful?