Skip to main content

API Reference

Getting the Singleton

var _mwa = null

func _ready() -> void:
if Engine.has_singleton("InvokeMWA"):
_mwa = Engine.get_singleton("InvokeMWA")

Signals

authorized(auth_token: String, address: String)

Emitted when authorize() succeeds. address is the wallet public key in base58.

reauthorized(auth_token: String)

Emitted when reauthorize() or tryReauthorizeFromCache() succeeds silently.

deauthorized()

Emitted when deauthorize() or disconnectWallet() completes.

transaction_signed(signatures: Array)

Emitted when signTransactions() or signMemoTransaction() succeeds.

transaction_sent(signatures: Array)

Emitted when signAndSendTransactions() or signAndSendMemoTransaction() succeeds. Contains transaction signatures (base58).

message_signed(signatures: Array)

Emitted when signMessages() or signMemoMessage() succeeds.

capabilities_received(json: String)

Emitted when getCapabilities() succeeds. Contains wallet capabilities as JSON string.

wallet_apps_detected(json: String)

Emitted when getInstalledWallets() completes. Contains installed wallet list as JSON.

mwa_error(code: int, message: String)

Emitted when any operation fails. See Error Codes.


Methods

Authorization

authorize(cluster, name, uri, icon)

Opens the system wallet picker and requests authorization.

_mwa.authorize("solana:devnet", "My Game", "https://mygame.dev", "https://mygame.dev/icon.png")
ParameterTypeDescription
clusterString"solana:devnet", "solana:testnet", "solana:mainnet-beta"
nameStringApp name shown in wallet UI
uriStringApp URL (must start with https://)
iconStringFull URL to app icon

reauthorize(auth_token, name, uri, icon)

Refreshes an existing session. May show wallet picker if token is stale.


deauthorize(auth_token)

Tells the wallet to invalidate this token server-side.


tryReauthorizeFromCache(name, uri, icon)

Reads auth token from encrypted cache and reauthorizes automatically. This is the recommended pattern for app startup.

func _ready() -> void:
if _mwa.cacheHasToken():
_mwa.tryReauthorizeFromCache("My Game", "https://mygame.dev", "https://mygame.dev/icon.png")
else:
show_connect_button()

disconnectWallet()

Clears the cached token instantly. Does NOT call the wallet — no popup. Use for your Disconnect button.

_mwa.disconnectWallet()
# Then listen for deauthorized signal

Signing

signTransactions(transactions)

Signs one or more raw transactions (Base64 encoded). Does not broadcast.

_mwa.signTransactions(["BASE64_TX_BYTES"])

signAndSendTransactions(transactions, min_context_slot)

Signs and broadcasts transactions to the Solana network.

_mwa.signAndSendTransactions(["BASE64_TX_BYTES"], 0)

signMessages(messages, addresses)

Signs arbitrary messages off-chain (no transaction, no network).

_mwa.signMessages(["BASE64_MSG_BYTES"], ["BASE64_ADDRESS_BYTES"])

Convenience Methods

These build real Solana transactions internally — no transaction construction needed in GDScript.

signMemoTransaction(memo, rpc_url)

Builds a real memo transaction, fetches a fresh blockhash from RPC, and requests a signature. Emits transaction_signed.

_mwa.signMemoTransaction("Hello Solana", "https://api.devnet.solana.com")

signAndSendMemoTransaction(memo, rpc_url)

Builds, signs, and broadcasts a memo transaction. Emits transaction_sent with the transaction signature.

_mwa.signAndSendMemoTransaction("Hello Solana", "https://api.devnet.solana.com")

signMemoMessage(message)

Signs a plain text message off-chain. Emits message_signed.

_mwa.signMemoMessage("Hello Solana")

Discovery

getCapabilities()

Queries the connected wallet for supported MWA features. Emits capabilities_received.

Clone Authorization note: supports_clone_authorization is in the MWA 2.0.3 spec and the SDK queries it correctly. Current wallets (Solflare, Jupiter) return false — this is expected, not a bug. It will work automatically when wallets ship support. Use cases: multi-device gaming, game + companion app sharing one wallet session.

getInstalledWallets()

Detects MWA-compatible wallet apps installed on the device. Emits wallet_apps_detected.


Cache Inspection

_mwa.cacheHasToken()       # bool — token exists in cache
_mwa.cacheGetAddress() # String — cached wallet address
_mwa.cacheGetAgeSeconds() # int — seconds since token was cached
_mwa.cacheIsStale() # bool — true if older than 30 minutes
_mwa.cacheClear() # clear active wallet token
_mwa.cacheClearAll() # clear all cached tokens

Error Codes

CodeConstantRetryableCause
1001USER_DECLINEDNoUser tapped Reject in wallet
1002WALLET_NOT_INSTALLEDNoNo MWA wallet found on device
1003SESSION_ALREADY_ACTIVENoConcurrent session blocked
1004AUTH_TOKEN_INVALIDYesToken rejected by wallet
1005AUTH_TOKEN_EXPIREDYesToken too old, re-auth required
2001TRANSACTION_EXPIREDYesBlockhash expired
2002TRANSACTION_FAILEDNoOn-chain rejection
2003SIMULATION_FAILEDNoPreflight simulation failed
2004INSUFFICIENT_FUNDSNoNot enough SOL
2005BLOCKHASH_NOT_FOUNDYesRPC blockhash fetch failed
3001NETWORK_TIMEOUTYesNetwork request timed out
3002RPC_ERRORYesRPC endpoint error
9999UNKNOWNNoUnmapped exception