public class CasperSdk
extends java.lang.Object
| Constructor and Description |
|---|
CasperSdk(java.lang.String url,
int port) |
| Modifier and Type | Method and Description |
|---|---|
java.security.PublicKey |
createPublicKey(java.lang.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(java.io.InputStream jsonStream)
Converts a JSON object to a
Deploy. |
Deploy |
deployFromJson(java.lang.String json)
Converts a JSON object to a
Deploy. |
java.lang.String |
deployToJson(Deploy deploy)
Converts a Casper type object ot a JSON string
|
java.math.BigInteger |
getAccountBalance(java.security.PublicKey accountKey)
Obtains the account balance at a certain global state root hash.
|
java.lang.String |
getAccountHash(java.security.PublicKey accountKey)
Obtains the account public key hashed using BLAKE2_B_256 as a hex encode string
|
java.lang.String |
getAccountInfo(java.security.PublicKey accountKey)
Obtains the account info JSON
|
URef |
getAccountMainPurseURef(java.security.PublicKey accountKey)
Obtains an on-chain account's main purse unforgeable reference.
|
java.lang.String |
getAuctionInfo() |
java.lang.String |
getBlockInfo(Digest hash)
Obtains a block info by the block's hash
|
java.lang.String |
getBlockInfoByHeight(java.lang.Number height)
Obtains a block info by the block's height
|
java.lang.String |
getBlockTransfers()
Returns on-chain block transfers information as JSON
|
java.lang.String |
getBlockTransfers(java.lang.String blockHash)
Returns on-chain block transfers information as JSON for a specific block hash
|
ContractHash |
getContractHash(java.security.PublicKey accountKey)
Obtains the contract has from the account info
|
Deploy |
getDeploy(Digest deployHash)
Obtains deploy from the network
|
java.lang.String |
getEraInfoBySwitchBlock()
Obtains the chain ero info by switch block as JSON
|
java.lang.String |
getLatestBlockInfo()
Obtains the latest block info from a mode
|
java.lang.String |
getNodeMetrics()
Obtains the node metrics as JSON
|
java.lang.String |
getNodePeers() |
java.lang.String |
getNodeStatus() |
byte[] |
getPublicKeyBytes(java.security.PublicKey publicKey)
Obtains the bytes of a public key in casper format with the first byte being the algorithm type identifier
value.
|
java.lang.String |
getRpcSchema()
Obtain the RPC Schema as a JSON string
|
java.lang.String |
getStateRootHash()
Returns a root hash of global state
|
<T extends java.security.Key> |
loadKey(java.io.InputStream in)
Loads a single public or private key from a .pem in the provided stream
|
java.security.KeyPair |
loadKeyPair(java.io.InputStream publicKeyIn,
java.io.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,
java.lang.Number payment,
java.io.InputStream wasmIn,
int tokenDecimals,
java.lang.String tokenName,
java.lang.String tokenSymbol,
java.lang.Number tokenTotalSupply)
Creates an install contract deploy
|
Deploy |
makeInvokeContract(DeployParams deployParams,
java.lang.Number payment,
java.lang.Number amount,
java.security.PublicKey operatorKey,
java.security.PublicKey recipient)
Creates a new invoke contract delpoy
|
Deploy |
makeNativeTransfer(DeployParams deployParams,
java.lang.Number amount,
java.security.PublicKey target,
java.lang.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,
java.lang.Number amount,
int delegationRate,
java.security.PublicKey validatorPublicKey,
java.io.InputStream wasmIn)
Creates a validator auction bid deploy.
|
Deploy |
makeValidatorAuctionBidWithdrawal(DeployParams deployParams,
java.lang.Number amount,
java.security.PublicKey validatorPublicKey,
java.io.InputStream wasmIn,
URef unbondPurse)
Creates an auction bid withdraw delegation deploy.
|
Deploy |
makeValidatorDelegation(DeployParams deployParams,
java.lang.Number amount,
java.security.PublicKey delegatorPublicKey,
java.security.PublicKey validatorPublicKey,
java.io.InputStream wasmIn)
Creates a standard delegation deploy
|
Deploy |
makeValidatorDelegationWithdrawal(DeployParams deployParams,
java.lang.Number amount,
java.security.PublicKey delegatorPublicKey,
java.security.PublicKey validatorPublicKey,
java.io.InputStream wasmIn)
Creates a standard withdraw delegation deploy.
|
Transfer |
newTransfer(java.lang.Number amount,
java.security.PublicKey target,
java.lang.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,
java.security.KeyPair signKeyPair)
Sign the deploy with the specified signKeyPair.
|
ModuleBytes |
standardPayment(java.lang.Number paymentAmount)
Creates a new standard payment.
|
CLPublicKey |
toCLPublicKey(java.security.PublicKey publicKey)
Converts a java security public key to a Casper Labs public key
|
public java.lang.String getAccountInfo(java.security.PublicKey accountKey)
accountKey - An account holder's public keypublic ContractHash getContractHash(java.security.PublicKey accountKey)
accountKey - an account holder's public keypublic java.math.BigInteger getAccountBalance(java.security.PublicKey accountKey)
accountKey - they of the accountpublic URef getAccountMainPurseURef(java.security.PublicKey accountKey)
accountKey - key of an on-chain account.public java.lang.String getStateRootHash()
public java.lang.String getAccountHash(java.security.PublicKey accountKey)
accountKey - the public key to hashpublic java.lang.String getAuctionInfo()
public java.lang.String getNodeStatus()
public java.lang.String getNodePeers()
public Deploy deployFromJson(java.io.InputStream jsonStream) throws java.io.IOException
Deploy.jsonStream - the input stream to read the JSON object fromDeploygijava.io.IOException - - if there was an error reading the streampublic Deploy deployFromJson(java.lang.String json) throws java.io.IOException
Deploy.json - the input JSON to read tDeployjava.io.IOException - - if there was an error reading the jsonpublic Deploy makeValidatorDelegation(DeployParams deployParams, java.lang.Number amount, java.security.PublicKey delegatorPublicKey, java.security.PublicKey validatorPublicKey, java.io.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, java.lang.Number amount, java.security.PublicKey delegatorPublicKey, java.security.PublicKey validatorPublicKey, java.io.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, java.security.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 java.security.KeyPair loadKeyPair(java.io.InputStream publicKeyIn,
java.io.InputStream privateKeyIn)
publicKeyIn - the public key .pem file input streamprivateKeyIn - the private key .pem file input streampublic <T extends java.security.Key> T loadKey(java.io.InputStream in)
T - the type of the keyin - the stream for a .pem filepublic byte[] getPublicKeyBytes(java.security.PublicKey publicKey)
publicKey - the public key to extract the bytes frompublic ModuleBytes standardPayment(java.lang.Number paymentAmount)
paymentAmount - the number of notes paying to execution enginepublic Transfer newTransfer(java.lang.Number amount, java.security.PublicKey target, java.lang.Number id)
amount - the amount to transfertarget - the public key of the target accountid - the optional ID name argument valuepublic java.lang.String deployToJson(Deploy deploy) throws java.io.IOException
deploy - the type object to writejava.io.IOException - - on write errorpublic java.lang.String getNodeMetrics()
public java.security.PublicKey createPublicKey(java.lang.String publicKeyHex)
publicKeyHex - the public key hexpublic CLPublicKey toCLPublicKey(java.security.PublicKey publicKey)
publicKey - the public key to convertpublic java.lang.String getLatestBlockInfo()
public java.lang.String getBlockInfo(Digest hash)
hash - the has of the block info to obtainpublic java.lang.String getBlockInfoByHeight(java.lang.Number height)
height - the has of the block info to obtainpublic java.lang.String getBlockTransfers()
public java.lang.String getBlockTransfers(java.lang.String blockHash)
blockHash - the block hash to otain the transfers forpublic java.lang.String getEraInfoBySwitchBlock()
public java.lang.String getRpcSchema()
public Deploy makeValidatorAuctionBid(DeployParams deployParams, java.lang.Number amount, int delegationRate, java.security.PublicKey validatorPublicKey, java.io.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, java.lang.Number amount, java.security.PublicKey target, java.lang.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, java.lang.Number amount, java.security.PublicKey validatorPublicKey, java.io.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, java.lang.Number payment, java.io.InputStream wasmIn, int tokenDecimals, java.lang.String tokenName, java.lang.String tokenSymbol, java.lang.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, java.lang.Number payment, java.lang.Number amount, java.security.PublicKey operatorKey, java.security.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 user