I am trying to call a function from a modified ERC20 contract and I can't manage to make it work. I am doing this with web3j from Android.
I can connect to Infura. The contract is already deployed on Rinkeby. I checked everything and the address is good. I'm trying to create credentials from a private/public key pair and pass it to use gas from that account.
String publicKey = "0x1900a41f2777ab70aad2074e3F4B9c5429c7f243";
String privateKey = "some private key";
String sparkTokenAddr = "some_addr";
Credentials creds = Credentials.create(privateKey, publicKey);
SparkToken spark = SparkToken.load(
sparkTokenAddr, web3, creds, ManagedTransaction.GAS_PRICE, Contract.GAS_LIMIT);
try {
TransactionReceipt transactionReceipt = spark.chargedPhone(
BigInteger.valueOf(50), publicKey).send();
Log.e("ethereum", String.valueOf(transactionReceipt));
} catch (Exception e) {
e.printStackTrace();
Log.e("ethereum", "Could not send tx");
}
It always logs that the tx could not be sent. What do I do wrong?