I have blockchain extension for my project and want to extend android client to work with ethereum directly by using web3j. My current issue is get contract instance to execute mint function.
Contract has been deployed by using Remix IDE and Metamask account. Code snippets which shows work with chain use some token class instance with unclear nature: in some place it is assumed it should be provided with web3j package, in other place there is a reference it should be generated, eg with help of Truffle.
// Connect Web3j to the Blockchain
String rpcEndpoint = "http://localhost:8545";
Web3j web3j = Web3j.build(new HttpService(rpcEndpoint));
// Prepare a wallet
String pk = "0x5bbbef76458bf30511c9ee6ed56783644eb339258d02656755c68098c4809130";
// Account address: 0x1583c05d6304b6651a7d9d723a5c32830f53a12f
Credentials credentials = Credentials.create(pk);
// Load the contract
String contractAddress = "0xe4F275cE131eF87Cb8bF425E02D9215055e9F875";
ERC20 javaToken = ERC20.load(contractAddress, web3j, credentials, new DefaultGasProvider()
How do you get contract instance by having deployed contract address to mint a new token?
Web3j has abstract class Contract
which should be used as a parent class for yours ERC20
and ERC721
tokens implementation.
Under the hood they use an one of implementations of abstract class TransactionManager
to execute call on chain. For more information please check the source code of library .
Thanks to Jahangir Jadi for the clue and reference to web3j ERC20 implementation .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.