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.
Install from npm/yarn
$ yarn add @blocto/sdk
... or via CDN
<script src="https://unpkg.com/@blocto/sdk" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
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',
});
Parameter | Type | Description | Required |
---|---|---|---|
aptos.chainId | number | Aptos chain ID to connect to | Yes |
appId | String | Blocto dApp ID | Yes |
Aptos Mainnet
Aptos Testnet
const bloctoSDK = new BloctoSDK({
aptos: {
chainId: 1,
},
appId: 'YOUR_BLOCTO_APP_ID',
});
const bloctoSDK = new BloctoSDK({
aptos: {
chainId: 2,
},
appId: 'YOUR_BLOCTO_APP_ID',
});
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 modified 5mo ago