Open anandsemtech opened 2 years ago
How did you connect this library pls, can't seem to do that
This approach worked for me. You can try this
Generate the encoded contract abi using web3j https://docs.web3j.io/4.8.7/
val function = Function(
"{method name}",
listOf(
Address(from),
Address(to),
Uint256(BigInteger(tokenId)),
), // input parameters. Change this based on the method you're using
listOf(object : TypeReference<Utf8String>() {}) // output parameters. Change this based on the method you're using,
)
val encodedFunction = FunctionEncoder.encode(function)
Peform the Send Transaction method call with WalletConnect.
MainApplication.session?.performMethodCall(
Session.MethodCall.SendTransaction(
txRequest,
from = viewModel.address.value,
to = contractAddress,
nonce = nonce.transactionCount.toString(16),
gasPrice = DefaultGasProvider.GAS_PRICE.toString(16),
gasLimit = DefaultGasProvider.GAS_LIMIT.toString(16),
value = BigInteger.ZERO.toString(16),
data = endcodedFunction
)
) { resp ->
// do something with callback
}
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse("wc:")
context.startActivity(i)
Make sure that to to
parameter is the contract address you're interacting with
For some reason, this approach only works with Metamask v4.0.1 and does not work with Metamask's latest update v4.2.2. It might be a bug on their end.
@mendelordanza Can you explain in brief . I really need to connect with the metamask wallet using my smart contract. I have successfully connected with my wallet but when I try to perform a transaction, it redirected to metamask, but nothing happens. No dialog is showing. Now when I tried your method it is not importing any of the functions above although when I tried the same method in java it works ? Can you please refer me some tutorial or anything?
Successfully connected Metamask with this library. Now, How do I establish web3 connection to my contract and call the contract's method. Can you please provide me some examples?