io.web3service.web3j.contract.BaseErc20Contract Maven / Gradle / Ivy
The newest version!
package io.web3service.web3j.contract;
import org.web3j.abi.TypeReference;
import org.web3j.abi.datatypes.Address;
import org.web3j.abi.datatypes.Function;
import org.web3j.abi.datatypes.Type;
import org.web3j.abi.datatypes.Utf8String;
import org.web3j.abi.datatypes.generated.Uint256;
import org.web3j.abi.datatypes.generated.Uint8;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.RemoteCall;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.tx.Contract;
import org.web3j.tx.TransactionManager;
import org.web3j.tx.gas.ContractGasProvider;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
/**
* @author github.com/x-saofen
*/
public class BaseErc20Contract extends Contract {
public BaseErc20Contract(String contractBinary, String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider gasProvider) {
super(contractBinary, contractAddress, web3j, credentials, gasProvider);
}
public BaseErc20Contract(String contractBinary, String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider gasProvider) {
super(contractBinary, contractAddress, web3j, transactionManager, gasProvider);
}
public RemoteCall name() {
final Function function = new Function("name",
Arrays.asList(),
Arrays.>asList(new TypeReference() {
}));
return executeRemoteCallSingleValueReturn(function, String.class);
}
public RemoteCall approve(String _spender, BigInteger _value) {
final Function function = new Function(
"approve",
Arrays.asList(new Address(_spender),
new Uint256(_value)),
Collections.>emptyList());
return executeRemoteCallTransaction(function);
}
public RemoteCall totalSupply() {
final Function function = new Function("totalSupply",
Arrays.asList(),
Arrays.>asList(new TypeReference() {
}));
return executeRemoteCallSingleValueReturn(function, BigInteger.class);
}
public RemoteCall transferFrom(String _from, String _to, BigInteger _value) {
final Function function = new Function(
"transferFrom",
Arrays.asList(new Address(_from),
new Address(_to),
new Uint256(_value)),
Collections.>emptyList());
return executeRemoteCallTransaction(function);
}
public RemoteCall initialSupply() {
final Function function = new Function("INITIAL_SUPPLY",
Arrays.asList(),
Arrays.>asList(new TypeReference() {
}));
return executeRemoteCallSingleValueReturn(function, BigInteger.class);
}
public RemoteCall decimals() {
final Function function = new Function("decimals",
Arrays.asList(),
Arrays.>asList(new TypeReference() {
}));
return executeRemoteCallSingleValueReturn(function, BigInteger.class);
}
public RemoteCall decreaseApproval(String _spender, BigInteger _subtractedValue) {
final Function function = new Function(
"decreaseApproval",
Arrays.asList(new Address(_spender),
new Uint256(_subtractedValue)),
Collections.emptyList());
return executeRemoteCallTransaction(function);
}
public RemoteCall balanceOf(String _owner) {
final Function function = new Function("balanceOf",
Arrays.asList(new Address(_owner)),
Arrays.asList(new TypeReference() {
}));
return executeRemoteCallSingleValueReturn(function, BigInteger.class);
}
public RemoteCall symbol() {
final Function function = new Function("symbol",
Arrays.asList(),
Arrays.asList(new TypeReference() {
}));
return executeRemoteCallSingleValueReturn(function, String.class);
}
public RemoteCall transfer(String _to, BigInteger _value) {
final Function function = new Function(
"transfer",
Arrays.asList(new Address(_to),
new Uint256(_value)),
Collections.emptyList());
return executeRemoteCallTransaction(function);
}
public RemoteCall increaseApproval(String _spender, BigInteger _addedValue) {
final Function function = new Function(
"increaseApproval",
Arrays.asList(new Address(_spender),
new Uint256(_addedValue)),
Collections.emptyList());
return executeRemoteCallTransaction(function);
}
public RemoteCall allowance(String _owner, String _spender) {
final Function function = new Function("allowance",
Arrays.asList(new Address(_owner),
new Address(_spender)),
Arrays.asList(new TypeReference() {
}));
return executeRemoteCallSingleValueReturn(function, BigInteger.class);
}
}