Sign And Execute Transaction
import { TransactionBlock } from "@mysten/sui.js";
// Send Sui coin
const tx = new TransactionBlock();
const sampleSendCoinAmount = "100000";
const sampleReceiverAddress = "0x...";
const [coin] = tx.splitCoins(tx.gas, [tx.pure(sampleSendCoinAmount)]);
tx.transferObjects([coin], tx.pure(sampleReceiverAddress));
// SuiSignAndExecuteTransactionBlockInput
const payload = {
transactionBlock: tx,
options: {
showInput: true,
showEffects: true,
showEvents: true,
},
};
await window.cosmostation.sui.connect();
const response = await window.cosmostation.sui.signAndExecuteTransaction(
payload
);
request
Model
export interface SuiSignTransactionBlockInput {
transactionBlock: TransactionBlock;
account: WalletAccount;
chain: IdentifierString;
}
export interface SuiSignAndExecuteTransactionBlockInput
extends SuiSignTransactionBlockInput {
requestType?: ExecuteTransactionRequestType;
options?: SuiTransactionBlockResponseOptions;
}
export type SuiTransactionBlockResponseOptions = {
showInput?: boolean | undefined;
showEffects?: boolean | undefined;
showEvents?: boolean | undefined;
showObjectChanges?: boolean | undefined;
showBalanceChanges?: boolean | undefined;
};
Response
- SuiTransactionResponse (opens in a new tab)
- SuiTransactionBlock (opens in a new tab)
- TransactionEffects (opens in a new tab)
- TransactionEvents (opens in a new tab)
- SuiObjectChange (opens in a new tab)
- BalanceChange (opens in a new tab)
Model
export type SuiTransactionResponse = {
digest: TransactionDigest,
transaction: optional(SuiTransactionBlock),
effects: optional(TransactionEffects),
events: optional(TransactionEvents),
timestampMs: optional(string()),
checkpoint: optional(string()),
confirmedLocalExecution: optional(boolean()),
objectChanges: optional(array(SuiObjectChange)),
balanceChanges: optional(array(BalanceChange)),
/* Errors that occurred in fetching/serializing the transaction. */
errors: optional(array(string())),
};
Example
{
"digest": "ADxukibq4o4QqiMgr6QqtXnXczh5MGCQqMkgCKUW5NXT",
"transaction": {
"data": {
"messageVersion": "v1",
"transaction": {
"kind": "ProgrammableTransaction",
"inputs": [
{
"type": "pure",
"valueType": "u64",
"value": "1000000000"
},
{
"type": "object",
"objectType": "sharedObject",
"objectId": "0x0000000000000000000000000000000000000000000000000000000000000005",
"initialSharedVersion": "1",
"mutable": true
},
{
"type": "pure",
"valueType": "address",
"value": "0x184fbf9d6c2d2d3f27e27fe3ca2d3b4080bd406221e345e2d36633e638e988e1"
}
],
"transactions": [
{
"SplitCoins": [
"GasCoin",
[
{
"Input": 0
}
]
]
},
{
"MoveCall": {
"package": "0x0000000000000000000000000000000000000000000000000000000000000003",
"module": "sui_system",
"function": "request_add_stake",
"arguments": [
{
"Input": 1
},
{
"Result": 0
},
{
"Input": 2
}
]
}
}
]
},
"sender": "0x67b11c023bced7ae79530b653e81e37116836acf24d536e6ffbd4bf37159d3cf",
"gasData": {
"payment": [
{
"objectId": "0x63c8f9756ed686a70d8b6e4b60a05eed70de52c7a864a3eb1432294bc47521f6",
"version": 120,
"digest": "4eWN3j13gkCgmpF3ino3PyBnBGcr8TM9g7oXyLVcFvDf"
}
],
"owner": "0x67b11c023bced7ae79530b653e81e37116836acf24d536e6ffbd4bf37159d3cf",
"price": "990",
"budget": "10269000"
}
},
"txSignatures": [
"AOM7i8tZRt314VYWxtBr5DAUukOZJsRcX6YUZjKVzB/j0gyYqCMZ1mIVPFdM79VNXzEpS2Te8Ez7g878a13Ybwz6TRHL+z8z7uHmh38YqSzeZTJS1AuOfKSpuon1IV17MQ=="
]
},
"effects": {
"messageVersion": "v1",
"status": {
"status": "success"
},
"executedEpoch": "25",
"gasUsed": {
"computationCost": "990000",
"storageCost": "721559200",
"storageRebate": "713064528",
"nonRefundableStorageFee": "7202672"
},
"modifiedAtVersions": [
{
"objectId": "0x0000000000000000000000000000000000000000000000000000000000000005",
"sequenceNumber": "1999135"
},
{
"objectId": "0x5b890eaf2abcfa2ab90b77b8e6f3d5d8609586c3e583baf3dccd5af17edf48d1",
"sequenceNumber": "1999135"
},
{
"objectId": "0x63c8f9756ed686a70d8b6e4b60a05eed70de52c7a864a3eb1432294bc47521f6",
"sequenceNumber": "120"
}
],
"sharedObjects": [
{
"objectId": "0x0000000000000000000000000000000000000000000000000000000000000005",
"version": 1999135,
"digest": "DwbUaKPdp58kXHhh3WGzSnxv1uuzoEP55mmvrZyRqx8Q"
}
],
"transactionDigest": "ADxukibq4o4QqiMgr6QqtXnXczh5MGCQqMkgCKUW5NXT",
"created": [
{
"owner": {
"AddressOwner": "0x67b11c023bced7ae79530b653e81e37116836acf24d536e6ffbd4bf37159d3cf"
},
"reference": {
"objectId": "0xddd21c1a8b5d7a2bf1a6a689434c2dfe9b524bd5d66f140b54da3ee6b2a6c21f",
"version": 1999136,
"digest": "BEEN82jwzg2gku5meXogNQLz1zSnbv9rEFRVu7RhekPd"
}
}
],
"mutated": [
{
"owner": {
"Shared": {
"initial_shared_version": 1
}
},
"reference": {
"objectId": "0x0000000000000000000000000000000000000000000000000000000000000005",
"version": 1999136,
"digest": "CgnEEDYNDnAyFb6GzXwvCTC5X1RqAUEGkLQN59dn86Fn"
}
},
{
"owner": {
"ObjectOwner": "0x0000000000000000000000000000000000000000000000000000000000000005"
},
"reference": {
"objectId": "0x5b890eaf2abcfa2ab90b77b8e6f3d5d8609586c3e583baf3dccd5af17edf48d1",
"version": 1999136,
"digest": "7zdHAR9jtbEuaNroxVUUXGgMBJCVF9RRfQ1ACy4sGr8d"
}
},
{
"owner": {
"AddressOwner": "0x67b11c023bced7ae79530b653e81e37116836acf24d536e6ffbd4bf37159d3cf"
},
"reference": {
"objectId": "0x63c8f9756ed686a70d8b6e4b60a05eed70de52c7a864a3eb1432294bc47521f6",
"version": 1999136,
"digest": "4uYp4yEhf4kcKmdUSZmxao5nGo38mydK93w9Vj6GdmJy"
}
}
],
"gasObject": {
"owner": {
"AddressOwner": "0x67b11c023bced7ae79530b653e81e37116836acf24d536e6ffbd4bf37159d3cf"
},
"reference": {
"objectId": "0x63c8f9756ed686a70d8b6e4b60a05eed70de52c7a864a3eb1432294bc47521f6",
"version": 1999136,
"digest": "4uYp4yEhf4kcKmdUSZmxao5nGo38mydK93w9Vj6GdmJy"
}
},
"eventsDigest": "5MMMagM2CoBtWGL7x39i2H8FeF75LWfFzgZDpzc5YC1H",
"dependencies": [
"Ui22Hhc6NyVEnAhRWCWVT333JvvBWG75qJx9qBg9VE1",
"53k4PWPByFxMLEYu53coAPiFCoxoz1mkUnv2Nr73UFw1",
"6oLy1FVtkMhuknWGsz7cvyYhn5CZFGPnyLhXZYuBd8kh"
]
},
"events": [
{
"id": {
"txDigest": "ADxukibq4o4QqiMgr6QqtXnXczh5MGCQqMkgCKUW5NXT",
"eventSeq": "0"
},
"packageId": "0x0000000000000000000000000000000000000000000000000000000000000003",
"transactionModule": "sui_system",
"sender": "0x67b11c023bced7ae79530b653e81e37116836acf24d536e6ffbd4bf37159d3cf",
"type": "0x3::validator::StakingRequestEvent",
"parsedJson": {
"amount": "1000000000",
"epoch": "25",
"pool_id": "0x2f52ce5bfcc5d517a3bdc0c154ab1cbd3757822c5db6a3fa514b9cc81697f999",
"staker_address": "0x67b11c023bced7ae79530b653e81e37116836acf24d536e6ffbd4bf37159d3cf",
"validator_address": "0x184fbf9d6c2d2d3f27e27fe3ca2d3b4080bd406221e345e2d36633e638e988e1"
},
"bcs": "9tL9umBpTLeUxXFn24EEEukPeFNYNcg2nEcTog31dxEVVuZwseE4Q6FHCM5YNfG6PadX7n5RYyhfRN7cxhApcyMBJ3UfxWSWbzEvFTrKNrg5oq1FVCB2bz2uUsbQXv5xcAAoWFH6CQTcVBj3MyEZwQVHy"
}
],
"confirmedLocalExecution": true
}