SputnikVM C Bindings
Classes | Typedefs | Enumerations | Functions | Variables
sputnikvm.h File Reference

SputnikVM FFI Bindings. More...

Go to the source code of this file.

Classes

struct  sputnikvm_address
 
struct  sputnikvm_gas
 
struct  sputnikvm_u256
 
struct  sputnikvm_h256
 
struct  sputnikvm_transaction
 
struct  sputnikvm_header_params
 
struct  sputnikvm_require_value_account_storage
 
union  sputnikvm_require_value
 
struct  sputnikvm_require
 
struct  sputnikvm_log
 
struct  sputnikvm_account_change_value_balance
 
struct  sputnikvm_account_change_value_all
 
union  sputnikvm_account_change_value
 
struct  sputnikvm_account_change
 
struct  sputnikvm_account_change_storage
 

Typedefs

typedef unsigned char sputnikvm_action
 
typedef struct sputnikvm_vm_S sputnikvm_vm_t
 

Enumerations

enum  sputnikvm_require_type {
  none, account, account_code, account_storage,
  blockhash
}
 
enum  sputnikvm_account_change_type {
  increase_balance, decrease_balance, full, create,
  removed
}
 

Functions

sputnikvm_vm_tsputnikvm_new_frontier (sputnikvm_transaction transaction, sputnikvm_header_params header)
 
sputnikvm_vm_tsputnikvm_new_homestead (sputnikvm_transaction transaction, sputnikvm_header_params header)
 
sputnikvm_vm_tsputnikvm_new_eip150 (sputnikvm_transaction transaction, sputnikvm_header_params header)
 
sputnikvm_vm_tsputnikvm_new_eip160 (sputnikvm_transaction transaction, sputnikvm_header_params header)
 
sputnikvm_require sputnikvm_fire (sputnikvm_vm_t *vm)
 
void sputnikvm_free (sputnikvm_vm_t *vm)
 
int sputnikvm_commit_account (sputnikvm_vm_t *vm, sputnikvm_address address, sputnikvm_u256 nonce, sputnikvm_u256 balance, unsigned char *code, unsigned int code_len)
 
int sputnikvm_commit_account_code (sputnikvm_vm_t *vm, sputnikvm_address address, unsigned char *code, unsigned int code_len)
 
int sputnikvm_commit_account_storage (sputnikvm_vm_t *vm, sputnikvm_address address, sputnikvm_u256 key, sputnikvm_u256 value)
 
int sputnikvm_commit_nonexist (sputnikvm_vm_t *vm, sputnikvm_address address)
 
int sputnikvm_commit_blockhash (sputnikvm_vm_t *vm, sputnikvm_u256 number, sputnikvm_h256 hash)
 
unsigned int sputnikvm_logs_len (sputnikvm_vm_t *vm)
 
void sputnikvm_logs_copy_info (sputnikvm_vm_t *vm, sputnikvm_log *log, unsigned int log_len)
 
sputnikvm_u256 sputnikvm_logs_topic (sputnikvm_vm_t *vm, unsigned int log_index, unsigned int topic_index)
 
void sputnikvm_logs_copy_data (sputnikvm_vm_t *vm, unsigned int log_index, unsigned char *data, unsigned int data_len)
 
unsigned int sputnikvm_account_changes_len (sputnikvm_vm_t *vm)
 
void sputnikvm_account_changes_copy_info (sputnikvm_vm_t *vm, sputnikvm_account_change *w, unsigned int len)
 
int sputnikvm_account_changes_copy_storage (sputnikvm_vm_t *vm, sputnikvm_address address, sputnikvm_account_change_storage *w, unsigned int len)
 
int sputnikvm_account_changes_copy_code (sputnikvm_vm_t *vm, sputnikvm_address address, unsigned char *w, unsigned int len)
 
sputnikvm_gas sputnikvm_used_gas (sputnikvm_vm_t *vm)
 
sputnikvm_transaction sputnikvm_default_transaction (void)
 
sputnikvm_header_params sputnikvm_default_header_params (void)
 

Variables

const unsigned char CALL_ACTION
 
const unsigned char CREATE_ACTION
 

Detailed Description

SputnikVM FFI Bindings.

Author
Wei Tang

Typedef Documentation

typedef unsigned char sputnikvm_action

Action item used in a transaction, can be either CALL_ACTION or CREATE_ACTION.

typedef struct sputnikvm_vm_S sputnikvm_vm_t

Enumeration Type Documentation

Enumerator
increase_balance 
decrease_balance 
full 
create 
removed 
Enumerator
none 
account 
account_code 
account_storage 
blockhash 

Function Documentation

int sputnikvm_account_changes_copy_code ( sputnikvm_vm_t vm,
sputnikvm_address  address,
unsigned char *  w,
unsigned int  len 
)

Copy code for a single account change entry.

void sputnikvm_account_changes_copy_info ( sputnikvm_vm_t vm,
sputnikvm_account_change w,
unsigned int  len 
)

Copy account change information.

int sputnikvm_account_changes_copy_storage ( sputnikvm_vm_t vm,
sputnikvm_address  address,
sputnikvm_account_change_storage w,
unsigned int  len 
)

Copy storage value for a single account change entry. Note that storage values are unordered.

unsigned int sputnikvm_account_changes_len ( sputnikvm_vm_t vm)

Get the account change length after the VM has exited.

int sputnikvm_commit_account ( sputnikvm_vm_t vm,
sputnikvm_address  address,
sputnikvm_u256  nonce,
sputnikvm_u256  balance,
unsigned char *  code,
unsigned int  code_len 
)

Commit a full account value into the VM. Should be used together with RequireError.

int sputnikvm_commit_account_code ( sputnikvm_vm_t vm,
sputnikvm_address  address,
unsigned char *  code,
unsigned int  code_len 
)

Commit a partial account code value into the VM. Should be used together with RequireError.

int sputnikvm_commit_account_storage ( sputnikvm_vm_t vm,
sputnikvm_address  address,
sputnikvm_u256  key,
sputnikvm_u256  value 
)

Commit a single account storage key-value pair into the VM. Should be used together with RequireError.

int sputnikvm_commit_blockhash ( sputnikvm_vm_t vm,
sputnikvm_u256  number,
sputnikvm_h256  hash 
)

Commit a block hash value with the specified block number. Should be used together with RequireError.

int sputnikvm_commit_nonexist ( sputnikvm_vm_t vm,
sputnikvm_address  address 
)

Mark a given required account as not-existing. Should be used together with RequireError.

sputnikvm_header_params sputnikvm_default_header_params ( void  )

Default all-zero header parameter value.

sputnikvm_transaction sputnikvm_default_transaction ( void  )

Default all-zero transaction value.

sputnikvm_require sputnikvm_fire ( sputnikvm_vm_t vm)

Execute the VM until it reaches a require error.

void sputnikvm_free ( sputnikvm_vm_t vm)

Free a VM instance.

void sputnikvm_logs_copy_data ( sputnikvm_vm_t vm,
unsigned int  log_index,
unsigned char *  data,
unsigned int  data_len 
)

Copy the data field of the given log.

void sputnikvm_logs_copy_info ( sputnikvm_vm_t vm,
sputnikvm_log log,
unsigned int  log_len 
)

Copy the appended VM logs information after the VM has exited.

unsigned int sputnikvm_logs_len ( sputnikvm_vm_t vm)

Return the length of the logs after the VM has exited.

sputnikvm_u256 sputnikvm_logs_topic ( sputnikvm_vm_t vm,
unsigned int  log_index,
unsigned int  topic_index 
)

Get the given VM logs topic. The log_index and topic_index must be within the limit fetched from logs_len and logs_info.

sputnikvm_vm_t* sputnikvm_new_eip150 ( sputnikvm_transaction  transaction,
sputnikvm_header_params  header 
)

Create a new EIP150 patch EVM instance using the given transaction and header parameters.

sputnikvm_vm_t* sputnikvm_new_eip160 ( sputnikvm_transaction  transaction,
sputnikvm_header_params  header 
)

Create a new EIP160 patch EVM instance using the given transaction and header parameters.

sputnikvm_vm_t* sputnikvm_new_frontier ( sputnikvm_transaction  transaction,
sputnikvm_header_params  header 
)

Create a new frontier patch EVM instance using the given transaction and header parameters.

sputnikvm_vm_t* sputnikvm_new_homestead ( sputnikvm_transaction  transaction,
sputnikvm_header_params  header 
)

Create a new homestead patch EVM instance using the given transaction and header parameters.

sputnikvm_gas sputnikvm_used_gas ( sputnikvm_vm_t vm)

Return the used gas after the VM has exited.

Variable Documentation

const unsigned char CALL_ACTION
const unsigned char CREATE_ACTION