elrond.Account Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of erdjava Show documentation
Show all versions of erdjava Show documentation
The Java 1.8 SDK for interacting with the Elrond blockchain
package elrond;
import java.io.IOException;
import java.math.BigInteger;
import elrond.Exceptions.AddressException;
import elrond.Exceptions.ProxyRequestException;
public class Account {
private final Address address;
private long nonce = 0;
private BigInteger balance = BigInteger.valueOf(0);
public Account(Address address) {
this.address = address;
}
/**
* Synchronizes account properties with the ones queried from the Network
*
* @param provider the Network provider
* @throws IOException if HTTP call fails
* @throws AddressException if the address isn't correct
* @throws ProxyRequestException if there is an issue with the proxy request
*/
public void sync(IProvider provider) throws AddressException, IOException, ProxyRequestException {
AccountOnNetwork accountOnNetwork = provider.getAccount(this.address);
this.nonce = accountOnNetwork.getNonce();
this.balance = accountOnNetwork.getBalance();
}
public Address getAddress() {
return address;
}
public long getNonce() {
return nonce;
}
public void incrementNonce() {
this.nonce++;
}
public BigInteger getBalance() {
return balance;
}
}