Transaction
Structure
Definition​
Transaction is the main way of interaction between a user and a blockchain. Transaction contains:
- Signer account ID
- Receiver account ID
- Actions
SignedTransactionView
​
Transaction might be unsigned but from the indexer perspective when we think about Transaction we think about signed one
- Rust
- TypeScript
pub struct SignedTransactionView {
pub signer_id: AccountId,
pub public_key: PublicKey,
pub nonce: Nonce,
pub receiver_id: AccountId,
pub actions: Vec<ActionView>,
pub signature: Signature,
pub hash: CryptoHash,
}
export type Transaction = {
signerId: string;
publicKey: string;
nonce: number;
receiverId: string;
actions: Action[];
signature: string;
hash: string;
};
ActionView
​
ActionView
is an Enum with possible actions along with parameters. This structure is used in Transactions and in Receipts
- Rust
- TypeScript
pub enum ActionView {
CreateAccount,
DeployContract {
code: String,
},
FunctionCall {
method_name: String,
args: String,
gas: Gas,
#[serde(with = "u128_dec_format")]
deposit: Balance,
},
Transfer {
#[serde(with = "u128_dec_format")]
deposit: Balance,
},
Stake {
#[serde(with = "u128_dec_format")]
stake: Balance,
public_key: PublicKey,
},
AddKey {
public_key: PublicKey,
access_key: AccessKeyView,
},
DeleteKey {
public_key: PublicKey,
},
DeleteAccount {
beneficiary_id: AccountId,
},
}
export type Action =
| "CreateAccount"
| DeployContractAction
| FunctionCallAction
| TransferAction
| StakeAction
| AddKeyAction
| DeleteKeyAction
| DeleteAccountAction;
export type DeployContractAction = {
DeployContract: {
code: string;
};
};
export type FunctionCallAction= {
FunctionCall: {
methodName: string;
args: string;
gas: number;
deposit: string;
};
};
export type TransferAction = {
Transfer: {
deposit: string;
};
};
export type StakeAction = {
Stake: {
stake: number;
publicKey: string;
};
};
export type AddKeyAction = {
AddKey: {
publicKey: string;
accessKey: AccessKey;
};
};
export type DeleteKeyAction = {
DeleteKey: {
publicKey: string;
};
};
export type DeleteAccountAction = {
DeleteAccount: {
beneficiaryId: string;
};
};