Your First Dapp with StarKey
Create your first Dapp using StarKey wallet, the official wallet of Supra
Setup the project
Start building
Initialize the supraProvider
and state hooks
supraProvider
and state hooks supraProvider
- used to interact with StarKey wallet.
isStarKeyInstalled
- boolean value of StarKey extension installation status
accounts
- Array of connected accounts
networkData
- Chain ID for the connected network
All code from this step forward will be included within the App()
function.
Handle wallet connections
The following code will handle the wallet connections, triggered through a button click (which we will setup later) or an emitted event from the StarKey object.
When a wallet is connected, the accounts must be updated. When a wallet is disconnected, we must clear the stored accounts and network data.
Send a transaction
The following code creates a raw payload that calls the transfer
function of the supra_account
module. Once the raw transaction payload is created, it uses the supraProvider.sendTransaction
function to prompted the connect wallet to sign and submit.
It will transfer 1 supra
to the address 0x8de4158b48633d853186d5fc790718e5821d7d3c4855e06bcd97b105389a7d0f
.
Last updated