Sign & Send a Transaction
A web application may create an unsigned transaction and request Adena to sign and send the transaction with the connected account via the
doContract
method. Upon receiving the request, Adena will prompt the user to approve the transaction. If the user approves the transaction, Adena will use the user's private key to sign the transaction to create a signed transaction and broadcast it immediately.
adena.DoContract({
messages: [
{
type: "string",
value: object
},
// you may add additional messages within the brackets
...
],
gasFee: number,
gasWanted: number,
memo?: string
})
Key | Type | Description |
---|---|---|
message.type | string | "/bank.MsgSend" for transfers"/vm.m_call" for contract calls
"/vm.m_addpkg" for adding packages |
message.value | object | Values (must match the type's format) |
gasFee | number | Actual network fee to pay in ugnot |
gasWanted | number | Gas limit |
memo | string | Transaction memo (tag) |
Key | Type | Description |
---|---|---|
code | number | Account number |
status | string | Returns success or failure |
type | string | Response type |
message | string | Descriptive message of the result |
data | object | Transaction Result Model |
Key | Type | Description |
---|---|---|
hash | string | Transaction hash |
height | string | Block height |
checkTx | object | Only returns on successful transactions |
deliverTx | object | Only returns on successful transactions |
await adena.DoContract(
{
messages: [{
type: "/bank.MsgSend",
value: {
from_address: "g1ffzxha57dh0qgv9ma5v393ur0zexfvp6lsjpae", // your Adena address
to_address: "g122n67es9vzs0rmharsggfr4sdkd45aysnuzf7m", // recipient's address
amount: "5000000ugnot" // sending amount. 1GNOT = 1000000ugnot
}
}],
gasFee: 1,
gasWanted: 1000000,
memo: "12313"
}
)
{
"code": 0,
"status": "success",
"type": "TRANSACTION_SENT",
"message": "The transaction has been successfully sent.",
"data": {
"height": "4027",
"hash": "SWHSwked0XUWk7R7UmW+iD4PgVugok/Pb7fW0Yf86qE=",
"deliverTx": {},
"checkTx": {}
}
}
await adena.DoContract(
{
messages: [{
type: "/vm.m_call",
value: {
caller: "g1ffzxha57dh0qgv9ma5v393ur0zexfvp6lsjpae", // your Adena address
send: "",
pkg_path: "gno.land/r/demo/foo20", // Gnoland package path
func: "Transfer", // Function name
args: [ // Arguments
"g122n67es9vzs0rmharsggfr4sdkd45aysnuzf7m",
"1"
]
}
}
],
gasFee: 1,
gasWanted: 10000000
}
)
{
"code": 0,
"status": "success",
"type": "TRANSACTION_SENT",
"message": "The transaction has been successfully sent.",
"data": {
"height": "4027",
"hash": "SWHSwked0XUWk7R7UmW+iD4PgVugok/Pb7fW0Yf86qE=",
"deliverTx": {},
"checkTx": {}
}
}
await adena.DoContract({
messages: [{
type: "/vm.m_addpkg",
value: {
creator: "g1ffzxha57dh0qgv9ma5v393ur0zexfvp6lsjpae", // your Adena address
deposit: "1ugnot", // amount of ugnot to deposit in the package (enter a blank or an amount above 1 ugnot)
package: {
Name: "hello", // package name
Path: "gno.land/r/demo/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
}
]
}
}
}],
gasFee: 1,
gasWanted: 2000000
});
{
"code": 0,
"status": "success",
"type": "TRANSACTION_SENT",
"message": "The transaction has been successfully sent.",
"data": {
"height": "4027",
"hash": "SWHSwked0XUWk7R7UmW+iD4PgVugok/Pb7fW0Yf86qE=",
"deliverTx": {},
"checkTx": {}
}
}
Last modified 19d ago