This project contains typescript SDK source code.
This project use AssemblyScript/assemblyscript as compile tool, before you compile your cotract to Ultrain supoort binary fomat, please install assemblyscritp at first.
to get the receiver's account name of current action. such as command 'clultrain push action kobe '["params"]' -p james's-key', 'kobe' is the receiver's account name.
to get the sender of current action, specially, 'sender' means whose permission key is used by '-p', such as command 'clultrain push action kobe '["params"]' -p james's-key', 'james' is the sender's account name.
to check if an account name has been authored.
the account name which will be checked.
boolean value, return true means the account is authored, otherwised false.
to check if an account name is valid or not.
account name to be checked.
boolean
check the authority of a speicfic account name.
account_name whose authority is required.
class ActionImpl is an internal class, for method {@link dispatchInline}.
class TransferParams is applied to transfer Tokens from an account to another.
the permission level instance. @see PermissionLevel
the account name of contract which you will send request to.
the action/method name which you will invoke of contract.
the TransferParams instance. @see TransferParams
to check if permission is authored or not.
PermissionLevel to check
The class Asset manages the digital assets which stored on the chain. A valid asset has two parts: amount and symbol. Different assets have different symbols. for example, "1000 UGS" and "1000 SYS" are both valid assets, but they are different. You can do +,-,*, / and logic compare such as ==,!=, <=, >= on assets with same symbol.
Clone an Asset object.
divide the asset with a factor.
divide factor.
Get the amount of Asset.
an uint64 value.
Get the encoded symbol. for example, if the symbol string is "ABC", then the symbol is 0x434241xx. Notice the last "xx" stands for the precisions.
To check if a symbol is valid or not. A valid symbol must fullfill two conditions:
To check if an Asset is valid or not.
multiple the asset with a factor.
multiple factor.
Set the amount of Asset.
new amount value.
Set new encoded symbol. Generate new symbol by calling function StringToSymbol
new symbol
Get symbol name without precision info.
Get the length of symbol name.
uint32
Get the precision of Asset.
query the balance of specific account.
account name for querying balance from.
Transfer some Assets from an account to another. It is an async method, if the operation failed, then an exception will be thrown and the transaction failed.
transfer Asset from this account.
transfer Asset to this account.
assets will be transfered.
a memo tip for this transaction.
ASCII code of character A.
ASCII code of character Z.
max amount of Asset, which is 2^62 - 1.
Encode a string to uint64 value, for example, let symbol = StringToSymbol(4, "ABC"); // symbol = 0x43424104 the precision number 4 means there are 4 digitals after ".", Asset "100.0000 ABC" will match this symbol.
symbol precision
symbol as string
uint64 value.
retrieve symbol name length.
encoded symbol name.
uint32
class Account for Token system.
class CurrencyStats for Token system.
Ultrain block system Token, it's precision is 4, and symbol is "UGS".
Ultrain block system Token name "UGS".
to query the balance of an account from Ultrain Token system.
account name to be queried.
Asset
to send Token of UGS from an account to another.
from account
to account
Asset to send.
a string message
internal class, not for external users.
internal class, not for external users.
read array of complex class which implements ISerializable interface.
write array of complex class which implements ISerialzable interface.
make a DataStream from an existing array.
an array of basic class, like u8/i8, u16/i16, u32/i32, u64/i64
to measure the length of serialized buffer.
an instance of class which implements ISerializable.
internal memory HEADER SIZE. NEVER used by users.
class DBManager is used to manager reading or writing to system db. the type T must be implements interface ISerializable, reference Account or CurrencyStats
create a table to persistent data.
the table name
the owner of the table, who can read and write the table, anyone else is read-only. meanwhile, the owner should pay for storing data if need.
the scope of rows, if you write a row with scope A, then you must read the row with scope A too, otherwise you get nothing.
insert a new record to database.
an account_name, who pays for the storing action.
the data to be sotred.
remove a record from database.
data to be removed.
read a record form database.
the primary key of data
the data struct if success.
true if the primary key exists, otherwise false.
update a row.
account name who pays for the updating action.
the updated data to be stored.
describe a row of table.
class Logger providers api to print logs to console immediately after you call function 'flush'.
flush the logs to console, the message will output to the console only after calling this method, or the message concat together.
print an integer to console.
integer to print.
to print as dec or hex. for example, 'Log.i(10, 10).flush() ' will print '10', but 'Log.i(10, 16).flush()' will print 'A'.
print a string message to console.
message to print.
A global variable of Logger. There is only one Log object at the same time.
class NameEx uses to store 21 characters name, method NEX converts a string which contains "._0123456789abcdefghijklmnopqrstuvwxyzABCEDEFGHIJKLMNOPQRSTUVWXYZ" to NameEx. for example, action_name is an intance of NameEx.
convert NameEx to string.
convert a string to NameEx. There are some limits for param str:
a string to convert to NameEx
an instance of NameEx
convert NameEx.valueH, NameEx.valueL to a string.
high 64 bits of NameEx.
low 64 bits of NameEx.
Permission Level stands for '-p' paramters. for example, PermissionLevel(N("tom"), N("active")) equals '-p tom@active'
set value as return value. This value will be printed to console or return within response if you call API by POST method via https. Till now, type T can only be string or integer. NOTE: the return value doesn't mean the transaction is commited by blockchain, but means if the transaction is executed, the result will be it.
value will set as return value.
return an array to caller. It behaves like Return.
an array of returns value.
printable characters.
convert a string to uint64 encoded by Base32. so the string must follow below principles:
string to convert
a revert operation of method N
uint64 value
convert an uint64 to string.
uint64 to convert
string
print a string to console after wasm vm quit.
string to print.
convert string to usize. here, usize likes "const char*" in c/c++.
a utf-16 string of typescript.
usize
convert an utf-16 to utf-8 string array.
a typescript string
an array of uint8
assert an condition. if condition is false, vm throws an exception and quit executing.
condition to check.
help message
Generated using TypeDoc
class Action is applied to access an action's context information. This class is static.
Action