Errors
The StarKey Supra provider does not signal failure by rejecting. Every method on window.starkey.supra resolves, and encodes failure in the resolved value — null for a declined prompt, [] for “not connected”, or a status: 'Failed' field for an on-chain failure.
A try/catch around a Supra provider call will not catch a user rejection — the promise resolves with null. Check
the resolved value before using it. Code written against a rejecting provider will throw a TypeError on
null.length instead of showing your rejection message.
This is different from the Ethereum provider, which is EIP-1193 compliant and does reject with { code, message } error objects.
Failure model
| Method | Failure case | Resolved value |
|---|---|---|
connect() | User declines, or closes the prompt window | null |
accounts() / account() | Not connected | [] |
getChainId() | Not connected | null |
changeNetwork() | User declines, or unrecognized chainId | null |
balance() | Not connected, or unknown asset | null |
sendTransaction() / sendAutomationTransaction() / signTransaction() | User declines the confirmation prompt | null |
signMessage() / signHexMessage() | User declines the sign prompt | null |
waitForTransactionWithResult() | Invalid/unknown hash | null |
waitForTransactionWithResult() | Transaction failed on-chain | { status: 'Failed' } |
null is also what you get when the user dismisses the StarKey popup without answering, or when a pending request is cleared because the user disconnected your site from the StarKey UI. Treat null as “the user did not approve this” — not as an error to retry.
Checking a declined prompt
const accounts = await window.starkey.supra.connect()
if (!accounts?.length) {
// user declined, closed the prompt, or has no account for this network
return
}
// safe to use accounts[0]The same shape applies to every prompt-based call:
const txHash = await window.starkey.supra.sendTransaction(params)
if (txHash === null) {
// user declined the confirmation prompt
return
}const result = await window.starkey.supra.changeNetwork({ chainId: '8' })
if (result === null) {
// user declined the switch, or the chain ID is not one StarKey knows
return
}
console.log(result.chainId)changeNetwork returns null for both a declined prompt and an unrecognized chain ID — the two cases are not
distinguishable from the return value. Validate the chainId against the supported networks before
calling if you need to tell them apart.
On-chain failure vs. declined prompt
A transaction can also fail after being approved and submitted. waitForTransactionWithResult resolves successfully with status: 'Failed' and a vmStatus string describing the Move execution error:
{
hash: '0xbdc5016f166f49979fb51dbd0407d7bf561b68eb9c0ad5a2849e01441988b4e3',
status: 'Failed',
vmStatus: '...', // Move VM abort/error description
}Always check status on a resolved transaction result — a resolved promise does not mean the transaction succeeded on-chain.
Recommended handling
async function connectWallet() {
const accounts = await window.starkey.supra.connect()
if (!accounts?.length) {
// declined or dismissed — show a non-blocking message, don't retry automatically
return
}
// proceed with accounts[0]
}async function confirmTransaction(hash: string) {
const result = await window.starkey.supra.waitForTransactionWithResult({ hash })
if (result === null) {
// invalid hash — don't treat as pending, surface as an error immediately
return
}
if (result.status === 'Failed') {
// on-chain failure — surface result.vmStatus to the user/logs
return
}
// result.status === 'Success'
}Notes
- Never treat a resolved
Promiseas success. Check fornull/ empty array on every call before reading a property off the result. - Don’t retry a
nullresult from a prompt-based call automatically in a loop — it usually means a deliberate user action. - If the StarKey popup cannot be shown at all (for example the request is dropped before a prompt is created), the promise may stay pending rather than resolving. Guard long-lived flows with your own timeout rather than awaiting indefinitely.
Related pages
- Establish a Connection
- Sending a Transaction
- Signing Messages
- Network
- Ethereum Errors — the EIP-1193 error-code model, for contrast