The Adena Wallet SDK provides the necessary tools to integrate the Adena Wallet into JavaScript-based applications, enabling interactions with both the Adena Wallet and TM2 Wallet for signing transactions, managing accounts, and more.
The Adena Wallet SDK supports a wide range of functionalities beyond connecting wallets and fetching account details. Here are some additional key features you can implement.
Generate a AddPackage of the VM transaction message.
Example:
const tx = TransactionBuilder.create()
.messages(
makeAddPackageMessage({
creator: 'g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5',
deposit: '1ugnot',
package: {
name: "hello", // package name
path: "gno.land/r/g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5/hello", // package path (cannot be a duplicate from existing paths on Gnoland)
files: [ // a list of files to deploy
{
name: "hello.gno", // file name
body: "package hello\n\nfunc Hello() string {\n\treturn \"Hello() called\"\n}\n\nfunc Render() string {\n\treturn \"Render() called\"\n}", //file contents
}
]
}
}),
// You can add multiple messages
)
.memo('memo')
.build();
makeMsgCallMessage
Generate a MsgCall of the VM transaction message.
Example:
const tx = TransactionBuilder.create()
.messages(
makeMsgCallMessage({
caller: "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5", // your address
send: "",
pkg_path: "gno.land/r/demo/foo20", // Gnoland package path
func: "Transfer", // Function name
args: [ // Arguments
"g1ffzxha57dh0qgv9ma5v393ur0zexfvp6lsjpae",
"1"
]
}),
// You can add multiple messages
)
.memo('memo')
.build();
makeMsgRunMessage
Generates a MsgRun of the vm transaction message.
Example:
const tx = TransactionBuilder.create()
.messages(
makeMsgRunMessage({
caller: "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5", // your address
send: "",
package: {
files: [
{
name: "main.gno",
// MsgRun runs the main function.
body: 'package main\n\nfunc main() {\n\tprintln("HELLO WORLD")\n}',
},
],
name: "main",
path: "",
},
}),
// You can add multiple messages
)
.memo('memo')
.build();
Error Handling and Debugging
Use console.error to capture detailed logs for any issues encountered during interactions with the SDK. Ensure you handle promise rejections to avoid unexpected application crashes.
For example:
adenaSDK.connectWallet()
.then(() => {
// Proceed with further operations
})
.catch((error) => {
// Log detailed error
console.error('Error during wallet connection:', error);
// Handle errors gracefully, such as showing user-friendly messages in the UI
});