public class CasperSdk extends Object
| Modifier and Type | Method and Description |
|---|---|
PublicKey |
createPublicKey(String publicKeyHex)
Creates a public key from a hex string where the first byte is the algorithm type and the following bytes the raw
public key bytes.
|
Deploy |
deployFromJson(InputStream jsonStream)
Converts a JSON object to a
Deploy. |
Deploy |
deployFromJson(String json)
Converts a JSON object to a
Deploy. |
String |
deployToJson(Deploy deploy)
Converts a Casper type object ot a JSON string
|
BigInteger |
getAccountBalance(PublicKey accountKey)
Obtains the account balance at a certain global state root hash.
|
String |
getAccountHash(PublicKey accountKey)
Obtains the account public key hashed using BLAKE2_B_256 as a hex encode string
|
String |
getAccountInfo(PublicKey accountKey)
Obtains the account info JSON
|
URef |
getAccountMainPurseURef(PublicKey accountKey)
Obtains an on-chain account's main purse unforgeable reference.
|
String |
getAuctionInfo() |
String |
getBlockInfo(Digest hash)
Obtains a block info by the block's hash
|
String |
getBlockInfoByHeight(Number height)
Obtains a block info by the block's height
|
String |
getBlockTransfers()
Returns on-chain block transfers information as JSON
|
String |
getBlockTransfers(String blockHash)
Returns on-chain block transfers information as JSON for a specific block hash
|
ContractHash |
getContractHash(PublicKey accountKey)
Obtains the contract has from the account info
|
Deploy |
getDeploy(Digest deployHash)
Obtains deploy from the network
|
String |
getEraInfoBySwitchBlock()
Obtains the chain ero info by switch block as JSON
|
String |
getLatestBlockInfo()
Obtains the latest block info from a mode
|
String |
getNodeMetrics()
Obtains the node metrics as JSON
|
String |
getNodePeers() |
String |
getNodeStatus() |
byte[] |
getPublicKeyBytes(PublicKey publicKey)
Obtains the bytes of a public key in casper format with the first byte being the algorithm type identifier
value.
|
String |
getRpcSchema()
Obtain the RPC Schema as a JSON string
|
String |
getStateRootHash()
Returns a root hash of global state
|
<T extends Key> |
loadKey(InputStream in)
Loads a single public or private key from a .pem in the provided stream
|
KeyPair |
loadKeyPair(InputStream publicKeyIn,
InputStream privateKeyIn)
Loads the key pair from the provided streams
|
Deploy |
makeDeploy(DeployParams deployParams,
DeployExecutable session,
DeployExecutable payment)
Construct new unsigned deploy.
|
Deploy |
makeInstallContract(DeployParams deployParams,
Number payment,
InputStream wasmIn,
int tokenDecimals,
String tokenName,
String tokenSymbol,
Number tokenTotalSupply)
Creates an install contract deploy
|
Deploy |
makeInvokeContract(DeployParams deployParams,
Number payment,
Number amount,
PublicKey operatorKey,
PublicKey recipient)
Creates a new invoke contract delpoy
|
Deploy |
makeNativeTransfer(DeployParams deployParams,
Number amount,
PublicKey target,
Number correlationId)
Creates a native transfer deploy.
|
Deploy |
makeTransferDeploy(DeployParams deployParams,
DeployExecutable session,
DeployExecutable payment)
Construct new unsigned deploy for transfer purpose.
|
Deploy |
makeValidatorAuctionBid(DeployParams deployParams,
Number amount,
int delegationRate,
PublicKey validatorPublicKey,
InputStream wasmIn)
Creates a validator auction bid deploy.
|
Deploy |
makeValidatorAuctionBidWithdrawal(DeployParams deployParams,
Number amount,
PublicKey validatorPublicKey,
InputStream wasmIn,
URef unbondPurse)
Creates an auction bid withdraw delegation deploy.
|
Deploy |
makeValidatorDelegation(DeployParams deployParams,
Number amount,
PublicKey delegatorPublicKey,
PublicKey validatorPublicKey,
InputStream wasmIn)
Creates a standard delegation deploy
|
Deploy |
makeValidatorDelegationWithdrawal(DeployParams deployParams,
Number amount,
PublicKey delegatorPublicKey,
PublicKey validatorPublicKey,
InputStream wasmIn)
Creates a standard withdraw delegation deploy.
|
Transfer |
newTransfer(Number amount,
PublicKey target,
Number id)
Creates a new Transfer to the target account of the specified amount
|
Digest |
putDeploy(Deploy signedDeploy)
Send deploy to network
|
Deploy |
signDeploy(Deploy deploy,
KeyPair signKeyPair)
Sign the deploy with the specified signKeyPair.
|
ModuleBytes |
standardPayment(Number paymentAmount)
Creates a new standard payment.
|
CLPublicKey |
toCLPublicKey(PublicKey publicKey)
Converts a java security public key to a Casper Labs public key
|
public CasperSdk(String url, int port)
public String getAccountInfo(PublicKey accountKey)
accountKey - An account holder's public keypublic ContractHash getContractHash(PublicKey accountKey)
accountKey - an account holder's public keypublic BigInteger getAccountBalance(PublicKey accountKey)
accountKey - they of the accountpublic URef getAccountMainPurseURef(PublicKey accountKey)
accountKey - key of an on-chain account.public String getStateRootHash()
public String getAccountHash(PublicKey accountKey)
accountKey - the public key to hashpublic String getAuctionInfo()
public String getNodeStatus()
public String getNodePeers()
public Deploy deployFromJson(InputStream jsonStream) throws IOException
Deploy.jsonStream - the input stream to read the JSON object fromDeploygiIOException - - if there was an error reading the streampublic Deploy deployFromJson(String json) throws IOException
Deploy.json - the input JSON to read tDeployIOException - - if there was an error reading the jsonpublic Deploy makeValidatorDelegation(DeployParams deployParams, Number amount, PublicKey delegatorPublicKey, PublicKey validatorPublicKey, InputStream wasmIn)
deployParams - standard parameters used when creating a deployamount - the amount in motes to be delegated.delegatorPublicKey - public key of delegator.validatorPublicKey - public key of validatorwasmIn - input stream of a compiled delegate.wasm.public Deploy makeValidatorDelegationWithdrawal(DeployParams deployParams, Number amount, PublicKey delegatorPublicKey, PublicKey validatorPublicKey, InputStream wasmIn)
deployParams - standard parameters used when creating a deployamount - amount in motes to be delegateddelegatorPublicKey - public key of delegatorvalidatorPublicKey - public key of validatorwasmIn - to compiled delegate.wasmpublic Deploy makeTransferDeploy(DeployParams deployParams, DeployExecutable session, DeployExecutable payment)
deployParams - the deployment parameterssession - the session/transferpayment - the paymentpublic Deploy makeDeploy(DeployParams deployParams, DeployExecutable session, DeployExecutable payment)
deployParams - the deployment parameterssession - the session/transferpayment - the paymentpublic Deploy signDeploy(Deploy deploy, KeyPair signKeyPair)
deploy - unsigned Deploy objectsignKeyPair - the keypair to sign the deploy objectpublic Deploy getDeploy(Digest deployHash)
deployHash - the hash of the deploy object to obtainpublic Digest putDeploy(Deploy signedDeploy)
signedDeploy - Signed deploy objectpublic KeyPair loadKeyPair(InputStream publicKeyIn, InputStream privateKeyIn)
publicKeyIn - the public key .pem file input streamprivateKeyIn - the private key .pem file input streampublic <T extends Key> T loadKey(InputStream in)
T - the type of the keyin - the stream for a .pem filepublic byte[] getPublicKeyBytes(PublicKey publicKey)
publicKey - the public key to extract the bytes frompublic ModuleBytes standardPayment(Number paymentAmount)
paymentAmount - the number of notes paying to execution enginepublic Transfer newTransfer(Number amount, PublicKey target, Number id)
amount - the amount to transfertarget - the public key of the target accountid - the optional ID name argument valuepublic String deployToJson(Deploy deploy) throws IOException
deploy - the type object to writeIOException - - on write errorpublic String getNodeMetrics()
public PublicKey createPublicKey(String publicKeyHex)
publicKeyHex - the public key hexpublic CLPublicKey toCLPublicKey(PublicKey publicKey)
publicKey - the public key to convertpublic String getLatestBlockInfo()
public String getBlockInfo(Digest hash)
hash - the has of the block info to obtainpublic String getBlockInfoByHeight(Number height)
height - the has of the block info to obtainpublic String getBlockTransfers()
public String getBlockTransfers(String blockHash)
blockHash - the block hash to otain the transfers forpublic String getEraInfoBySwitchBlock()
public String getRpcSchema()
public Deploy makeValidatorAuctionBid(DeployParams deployParams, Number amount, int delegationRate, PublicKey validatorPublicKey, InputStream wasmIn)
deployParams - standard parameters used when creating a deploy.amount - amount in motes to be submitted as an auction bid.delegationRate - percentage charged to a delegator for provided servicevalidatorPublicKey - public key of validatorwasmIn - stream of compiled delegate.wasmpublic Deploy makeNativeTransfer(DeployParams deployParams, Number amount, PublicKey target, Number correlationId)
deployParams - standard parameters used when creating a deploy.amount - amount in motes to be transferred.target - target account public key.correlationId - identifier used to correlate transfer to internal systems.public Deploy makeValidatorAuctionBidWithdrawal(DeployParams deployParams, Number amount, PublicKey validatorPublicKey, InputStream wasmIn, URef unbondPurse)
deployParams - standard parameters used when creating a deploy.amount - amount in motes to be withdrawn from auction.validatorPublicKey - public key of validator.wasmIn - input stream of compiled delegate.wasm.unbondPurse - validator's * purse to which to withdraw fundpublic Deploy makeInstallContract(DeployParams deployParams, Number payment, InputStream wasmIn, int tokenDecimals, String tokenName, String tokenSymbol, Number tokenTotalSupply)
deployParams - standard parameters used when creating a deploy.payment - mount in motes to be offered as payment.wasmIn - path to erc20.wasm filetokenDecimals - number of decimal places within ERC-20 token to be minted.tokenName - name of ERC-20 token to be minted.tokenSymbol - symbol of ERC-20 token to be minted.tokenTotalSupply - total number of ERC-20 tokens to be issuedpublic Deploy makeInvokeContract(DeployParams deployParams, Number payment, Number amount, PublicKey operatorKey, PublicKey recipient)
deployParams - standard parameters used when creating a deploy.payment - amount in motes to be offered as paymentamount - amount of ERC-20 tokens to be transferred to useroperatorKey - operator account keyrecipient - public ket of recipient userCopyright © 2022. All rights reserved.