Skip to main content

Module types

Module types 

Source
Expand description

Core types for NEAR Protocol.

This module provides hand-rolled types based on NEAR RPC responses, designed for ergonomic use in client applications.

§Primary Types

TypeDescription
AccountIdValidated NEAR account identifier
NearTokenToken amount with yoctoNEAR (10⁻²⁴) precision
GasGas units for transactions
PublicKeyEd25519 or Secp256k1 public key
SecretKeyEd25519 or Secp256k1 secret key
CryptoHash32-byte SHA-256 hash (blocks, transactions)

§Amount Types

NearToken and Gas support both typed constructors and string parsing:

use near_kit::{NearToken, Gas};

// Typed constructors (compile-time safe, zero-cost)
let amount = NearToken::near(5);
let gas = Gas::tgas(30);

// String parsing (for runtime input)
let amount: NearToken = "5 NEAR".parse().unwrap();
let gas: Gas = "30 Tgas".parse().unwrap();

§Block References

BlockReference specifies which block state to query:

  • BlockReference::Finality(Finality::Final) — Fully finalized (default)
  • BlockReference::Finality(Finality::Optimistic) — Latest optimistic
  • BlockReference::Height(12345) — Specific block height
  • BlockReference::Hash(hash) — Specific block hash

§RPC Response Types

Types for RPC responses include AccountView, BlockView, FinalExecutionOutcome, and others.

Modules§

nep413
NEP-413: Off-chain message signing for authentication.

Structs§

AccessKey
Access key attached to an account.
AccessKeyDetails
Access key details (without block info, used in lists).
AccessKeyInfoView
Single access key info in list.
AccessKeyListView
Access key list from view_access_key_list RPC.
AccessKeyView
Access key information from view_access_key RPC.
AccountBalance
Simplified balance info.
AccountId
A NEAR account identifier.
AccountView
Account information from view_account RPC.
ActionError
An error that occurred during action execution.
ActionReceiptData
Action receipt data.
AddKeyAction
Add an access key.
BandwidthRequest
A single bandwidth request to a target shard.
BandwidthRequestBitmap
Bitmap for bandwidth request values.
BandwidthRequestsV1
Bandwidth requests data (V1).
BlockHeaderInnerLiteView
Block header inner lite (for light client proofs).
BlockHeaderView
Block header with full details.
BlockView
Block information from block RPC.
ChunkHeaderView
Chunk header with full details.
CongestionInfoView
Congestion information for a shard.
CreateAccountAction
Create a new account.
CryptoHash
A 32-byte SHA-256 hash used for block hashes, transaction hashes, etc.
CurrentEpochValidatorInfo
Current epoch validator information.
DataReceiptData
Data receipt data.
DataReceiverView
Data receiver for output data in action receipts.
DelegateAction
Delegate action for meta-transactions.
DelegateActionView
View of a delegate action in RPC responses.
DeleteAccountAction
Delete the account.
DeleteKeyAction
Delete an access key.
DeployContractAction
Deploy contract code.
DeployGlobalContractAction
Publish a contract to the global registry.
DeterministicAccountStateInitV1
Version 1 of deterministic account state initialization.
DeterministicStateInitAction
Deploy a contract with a deterministically derived account ID (NEP-616).
EpochValidatorInfo
Epoch validator info from validators RPC.
ExecutionMetadata
Execution metadata with gas profiling.
ExecutionOutcome
Execution outcome details.
ExecutionOutcomeWithId
Execution outcome with ID.
FinalExecutionOutcome
Final execution outcome from send_tx RPC.
FinalExecutionOutcomeWithReceipts
Final execution outcome with receipts (from EXPERIMENTAL_tx_status).
FunctionCallAction
Call a contract function.
FunctionCallPermission
Function call access key permission details.
Gas
Gas units for NEAR transactions.
GasKeyInfo
Gas key information.
GasPrice
Gas price response.
GasProfileEntry
Gas profile entry for detailed gas accounting.
KeyPair
A cryptographic key pair (secret key + public key).
LightClientBlockLiteView
Light client block lite view.
LightClientBlockView
Light client block view from next_light_client_block RPC.
MerklePathItem
Merkle path item for cryptographic proofs.
NearToken
A NEAR token amount with yoctoNEAR precision (10^-24 NEAR).
NextEpochValidatorInfo
Next epoch validator information.
NodeVersion
Node version information.
NonDelegateAction
Non-delegate action (for use within DelegateAction).
PublicKey
Ed25519 or Secp256k1 public key.
Receipt
Receipt from EXPERIMENTAL_tx_status.
SecretKey
Ed25519 or Secp256k1 secret key.
SendTxResponse
Response from send_tx RPC.
SendTxWithReceiptsResponse
Response from EXPERIMENTAL_tx_status RPC.
Signature
Cryptographic signature.
SignedDelegateAction
Signed delegate action.
SignedTransaction
A signed transaction ready to be sent.
SlashedValidator
Slashed validator from challenge results.
StakeAction
Stake NEAR for validation.
StateChangeWithCauseView
State change with its cause (from EXPERIMENTAL_changes RPC).
StatusResponse
Node status response.
SyncInfo
Sync information.
Transaction
An unsigned transaction.
TransactionView
Transaction view in outcome.
TransferAction
Transfer NEAR tokens.
TransferToGasKeyAction
Transfer NEAR to a gas key.
TrieSplit
Trie split information for resharding.
UseGlobalContractAction
Deploy a contract from the global registry.
ValidatorInfo
Validator information.
ValidatorKickoutView
Validator kickout information.
ValidatorStakeViewV1
Validator stake data.
ViewFunctionResult
View function result from call_function RPC.
WithdrawFromGasKeyAction
Withdraw NEAR from a gas key.

Enums§

AccessKeyPermission
Access key permission.
AccessKeyPermissionView
Access key permission from RPC.
Action
A transaction action.
ActionErrorKind
Specific kind of action error.
ActionView
Action view in transaction.
ActionsValidationError
Error validating actions in a transaction or receipt.
BandwidthRequests
Bandwidth requests for a chunk (versioned).
BlockReference
Reference to a specific block for RPC queries.
CompilationError
Wasm compilation error.
DelegateDecodeError
Error decoding a signed delegate action.
DepositCostFailureReason
Reason a deposit cost check failed on a gas key transaction.
DeterministicAccountStateInit
State initialization data for NEP-616 deterministic accounts.
ExecutionStatus
Per-receipt execution status.
FinalExecutionStatus
Overall transaction execution status.
Finality
Finality level for queries.
FunctionCallError
An error during function call execution.
GlobalContractDeployMode
Deploy mode for global contracts.
GlobalContractIdentifier
How a global contract is identified in the registry.
GlobalContractIdentifierView
Global contract identifier in RPC view responses.
HostError
Error from a host function call.
InvalidAccessKeyError
Error related to access key validation.
InvalidTxError
An error during transaction validation (before execution).
KeyType
Key type identifier.
MerkleDirection
Direction in merkle path.
MethodResolveError
Error resolving a method in Wasm.
Network
The NEAR network the client is connected to.
PrepareError
Error preparing a Wasm module.
ReceiptContent
Receipt content - action, data, or global contract distribution.
ReceiptValidationError
Error validating a receipt.
StateChangeCauseView
Cause of a state change.
StateChangeValueView
State change value.
StorageError
Internal storage error.
SyncCheckpoint
Sync checkpoint for block references.
TxExecutionError
Error returned by NEAR RPC when a transaction or receipt fails.
TxExecutionStatus
Transaction execution status for send_tx wait_until parameter.
ValidatorKickoutReason
Reason a validator was kicked out.
ValidatorStakeView
Validator stake (versioned).
WasmTrap
A trap during Wasm execution.

Constants§

DEFAULT_HD_PATH
Default BIP-32 HD derivation path for NEAR keys. NEAR uses coin type 397 per SLIP-44.
DEFAULT_WORD_COUNT
Default number of words in generated seed phrases.
DELEGATE_ACTION_PREFIX
NEP-461 prefix for delegate actions (meta-transactions). Value: 2^30 + 366 = 1073742190
STORAGE_AMOUNT_PER_BYTE
Cost per byte of storage in yoctoNEAR.

Traits§

IntoGas
Trait for types that can be converted into Gas.
IntoNearToken
Trait for types that can be converted into a NearToken.

Functions§

generate_seed_phrase
Generate a random BIP-39 seed phrase.