Title
Create new category
Edit page index title
Edit category
Edit link
Smart Contract Methods
sendTransaction
Transfers funds from one wallet address to another, using a specified number of Credits (CS) coins. Optional data can be sent to the receiver, as long as the data is formatted using Base58 formatting.
protected final void sendTransaction(String from, String to, double amount, byte... userData)
- “addressFrom” - address funds are sent from.
- “addressTo” - address that receives sent funds
- "amount" - number of transferred funds
- "userData" - data uploaded by the user
xxxxxxxxxxpublic void sendTransactionExample() { return sendTransaction(“addressFrom”, “addressTo”, amount, userData); }invokeExternalContract
Invokes a method from another smart contract:
Object invokeExternalContract(String contractAddress, String method, Object params)
- "ContractAddress" - is the smart contract address
- "Method" - is the method that needs to be invoked
- "Params" - are the smart contract parameters, passed as an object
public void invokeSmartContractMethod() { Object[] params = new Object[] { param1, param2 }; String resultStr = (String) invokeExternalContract("77GfsQD7peXrxTsjyNVCJmpWWBJAYA9oKy9FGZHb5mJt", "myMethod", params); }- Specify smart contract address, example:
tokenKey; - Smart contract method, example:
myMethod; - Specify method parameters, example:
Object[] params = new Object[] {param1, param2}; - Object
invokeExternalContract(String contractAddress, String method, Object... params).
getSeed
Generates a random 8 bit number used for development of gambling or gaming dApps.
byte[] getSeed()
xxxxxxxxxxpublic Long getSeedExample() { return ByteBuffer.wrap(getSeed()).getLong(); }getBalance
Returns the Credits (CS) coin balance for a wallet address.
BigDecimal getBalance(String addressBase58)
- "addressBase58" - the wallet address, in Base58 format
xxxxxxxxxxpublic BigDecimal getBalanceExample() { return getBalance(address); }getBlockchainTimeMills
Requests network time in milliseconds
long getBlockchainTimeMills()
xxxxxxxxxxlong getBlockchainTimeMillsExample() { return getBlockchainTimeMills(); }payable
This event is invoked when a smart contract receives Credits (CS) coins via the Smart Contract Method called "sendTransaction".
String payable(BigDecimal amount, byte[] userData)
This event is triggered within the Smart Contract AFTER the Smart Contract "sendTransaction" method has finalized.
If an exception occurs within this event code, then the "sendTransaction" method fails and no Credits (CS) is transferred and no transaction fees are charged.
xxxxxxxxxxString payable(BigDecimal amount, byte[] userData) { string receivedData = userData; ... }