Meta Transactions - Web3j

PHOTO EMBED

Sun Mar 17 2024 06:23:53 GMT+0000 (Coordinated Universal Time)

Saved by @katyno

String jsonMessageString = Files.readString(Paths.get("src/main/resources/data.json").toAbsolutePath());
JSONObject jsonObject = new JSONObject(jsonMessageString);
jsonObject.getJSONObject("message").put("from", credentials.getAddress());
jsonObject.getJSONObject("message").put("nonce", nonce);
jsonObject.getJSONObject("message").put("data", encodedFunction);

String modifiedJsonString = jsonObject.toString();
Sign.SignatureData signature = Sign.signTypedData(modifiedJsonString, credentials.getEcKeyPair());
content_copyCOPY

https://docs.web3j.io/4.10.0/use_cases/meta_transaction/