Aptos Dapps Integration
(Require app ver > 12.5.0)
Aptos testnetβ
REST API Open API spec: https://fullnode.testnet.aptoslabs.com/v1/spec#/
REST service: https://fullnode.testnet.aptoslabs.com/v1
Faucet service: https://faucet.testnet.aptoslabs.com
Genesis and waypoint: https://github.com/aptos-labs/aptos-genesis-waypoint/tree/main/testnet
Aptos devnetβ
REST API Open API spec: https://fullnode.devnet.aptoslabs.com/v1/spec#/
REST service: https://fullnode.devnet.aptoslabs.com/v1
Faucet service: https://faucet.devnet.aptoslabs.com
Dapp API
Forum post with discussion There will be some apis that certain wallets may add but there should be a few apis that are standard across wallets. This will make mass adoption easier and will make dapp developers' lives easier.
connect({network: 'mainnet' | 'testnet' | 'devnet'}),disconnect(), andisConnected()account()signAndSubmitTransaction(transaction: EntryFunctionPayload)signMessage(payload: SignMessagePayload)Event listening (
onAccountChanged(listener),onNetworkChanged(listener))
connect(), disconnect(), isConnected()β
It is important that dapps, aren't allow to send requests to the wallet until the user acknowledges that they want to see these requests.
connect({network: 'mainnet' | 'testnet' | 'devnet'})will prompt the userreturn
Promise<PublicAccount>
disconnect()allows the user to stop giving access to a dapp and also helps the dapp with state managementreturn
Promise<void>
isConnected()able to make requests to the wallet to get current state of connectionreturn
Promise<boolean>
account()β
Needs to be connected The dapp may want to query for the current connected account to get the address or public key.
account()no prompt to the userreturns
Promise<PublicAccount>
signAndSubmitTransaction(transaction: EntryFunctionPayload)β
We will be generate a transaction from payload(simple JSON) using the sdk and then sign and submit it to the wallet's node.
signAndSubmitTransaction(transaction: EntryFunctionPayload)will prompt the user with the transaction they are signingreturns
Promise<PendingTransaction>
signMessage(payload: SignMessagePayload)β
The most common usecase for this function is to verify identity, but there are a few other possible use cases. You may notice some wallets from other chains just provide an interface to sign arbitrary strings. This can be susceptible to man-in-the-middle attacks, signing string transactions, etc.
Types:
signMessage(payload: SignMessagePayload)prompts the user with thepayload.messageto be signedreturns
Promise<SignMessageResponse>
An example: signMessage({nonce: 1234034, message: "Welcome to dapp!", address: true, application: true, chainId: true })
This would generate the fullMessage to be signed and returned as the signature:
dApp Integration
dApps can make requests to the wallet from their website:
connect(): prompts the user to allow connection from the dApp (neccessary to make other requests)isConnected(): returns if the dApp has established a connection with the walletaccount(): gets the address of the account signed into the walletsignAndSubmitTransaction(transaction): signs the given transaction and submits to chainsignTransaction(transaction): signs the given transaction and returns it to be submitted by the dAppdisconnect(): Removes connection between dApp and wallet. Useful when the user wants to remove the connection.
Verify signature:
Last updated