This project implements the SDK to interact with a Casper Node. It wraps the Json-RPC requests and maps the results to Java objects.
- Java 8
- Gradle
- crypto-keys
./gradlew build
Using gradle:
implementation 'com.syntifi.casper:casper-sdk:0.2.1'Using maven:
<dependency>
<groupId>com.syntifi.casper</groupId>
<artifactId>casper-sdk</artifactId>
<version>0.2.1</version>
</dependency>casperService = CasperService.usingPeer("127.0.0.1","7777");Retrieve block info by a block identifier
JsonBlockData result = casperService.getBlock();JsonBlockData result = casperService.getBlock(new HeightBlockIdentifier(1234));JsonBlockData blockData = casperService.getBlock(new HashBlockIdentifier("--hash--"));Retrieve block transfers by a block identifier
TransferData transferData = casperService.getBlockTransfers();TransferData transferData = casperService.getBlockTransfers(new HeightBlockIdentifier(1234));TransferData transferData = casperService.getBlockTransfers(new HashBlockIdentifier("--hash--"));Retrieve the state root hash given the BlockIdentifier
StateRootHashData stateRootData = casperService.getStateRootHash();StateRootHashData stateRootData = casperService.getStateRootHash(new HeightBlockIdentifier(1234));StateRootHashData stateRootData = casperService.getStateRootHash(new HashBlockIdentifier("--hash--"));4. Query deploy
Get a Deploy from the network
DeployData deployData = casperService.getDeploy("--hash--");5. Query peers
Get network peers data
PeerData peerData = casperService.getPeerData();Retrieve a stored value from the network
StoredValueData result = casperService.getStateItem("--stateRootHash--", "key", Arrays.asList("The path components starting from the key as base"));Return the current status of the node
StatusData status = casperService.getStatus()Returns an Account from the network
AccountData account = casperService.getStateAccountInfo("--publicKey--", new HeightBlockIdentifier(1234));AccountData account = casperService.getStateAccountInfo("--publicKey--", new HashBlockIdentifier("--hash--"));Returns the Auction info for a given block
AuctionData auction = casperService.getStateAuctionInfo(new HeightBlockIdentifier(1234));AuctionData auction = casperServiceMainnet.getStateAuctionInfo(new HashBlockIdentifier("--hash--"));Returns an EraInfo from the network
EraInfoData eraInfoData = casperService.getEraInfoBySwitchBlock(new HeightBlockIdentifier(1234));EraInfoData eraInfoData = casperService.getEraInfoBySwitchBlock(new HashBlockIdentifier("--hash--"));Deploy deploy = CasperDeployService.buildTransferDeploy(from, to,
BigInteger.valueOf(2500000000L), "casper-test",
id, BigInteger.valueOf(100000000L), 1L, ttl, new Date(),
new ArrayList<>());
DeployResult deployResult = casperServiceTestnet.putDeploy(deploy);