Connect your games to the Solana blockchain. Access the Solana JSON RPC API from your Godot game. The plugin is written for Godot version 4 and up. It is currently not in the godot asset library.
Download the latest release and place the addons folder in the res:// root. The plugin will load when your project is reloaded. The plugin must be enabled in your project settings under the plugins tab.
Add a node of type SolanaClient.
You can set the client behavior such as cluster URL, commitment level and minimum context slot. You can also set if your calls will be synchronous or asynchronous.
The default value is to use synchronous calls. The methods should then be called with the await keyword as follows
var result = await $solana_client_node.get_latest_blockhash()
If you prefer to use asynchronous calls you can get the request responce through signals. A basic example could be
var blockhash_request_id = 0
func basic_get_blockhash_example():
blockhash_request_id = $solana_client_node.unique_id
$solana_client_node.rpc_response.connect(Callable(self, "handle_response"))
$solana_client_node.get_latest_blockhash()
func handle_response(id, value):
if id == blockhash_request_id:
print("Latest blockhash is:", value)
There are two signals in the SolanaClient node apart from the inherited signals.
There is an error signal and a rpc_response signal. The rpc_response signal would only be used when dealing with asynchronous calls as shown in the example. It will pass the request ID that was passed with the request. The unique ID class property will increment by one by each request and can be used to keep track the requests and responses.
The error signal can be used to get error information. The signal passes an error Identifier and a short description of the error. A list of possible errors can be found here: GRPC status codes.
When using synchronous calls the return values can also indicate errors. When an error occurred, the methods will return null. For asynchronous calls the return values will always be null.