thetatoken / theta-eth-rpc-adaptor

An adaptor that translates the Theta RPC APIs to the Ethereum RPC APIs
https://docs.thetatoken.org/
24 stars 11 forks source link

Revert reason: 'encoding/hex: invalid byte: U+007B '{''. #22

Closed coffeemuggg closed 3 years ago

coffeemuggg commented 3 years ago

I'm trying to deploy my contract on the Testnet but I am getting this error, any idea why?

Transaction 0x8a6d97950.... has failed with status: 0x0. Gas used: 10000000. Revert reason: 'encoding/hex: invalid byte: U+007B '{''.
jieyilong commented 3 years ago

Is it possible for you to share your contract and the Javascript code you used to deploy the contract? Thanks

coffeemuggg commented 3 years ago

yep, but I am not using javascript I am using the Web3j library.

https://beta-explorer.thetatoken.org/txs/0x8a6d97950ced0af2ffae04888fce1fce9cdeeb271e8381e05897f3ec4c250f55

private void createNft(){
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .readTimeout(5, TimeUnit.MINUTES)
                .connectTimeout(5, TimeUnit.MINUTES)
                .writeTimeout(5, TimeUnit.MINUTES)
                .build();
        Web3j web3 = Web3j.build(new HttpService("https://eth-rpc-api-testnet.thetatoken.org/rpc", okHttpClient));
        try {
            Credentials credentials = WalletUtils.loadCredentials(
                    "password1",
                    "src\\main\\resources\\0x78e2d2e2a915158f596578892A54a4CfBD7A78F4.keystore"
            );
            FastRawTransactionManager txMananger = new FastRawTransactionManager(web3, credentials, 365);
            Minty.deploy(
                    web3,
                    txMananger,
                    new CustomerGasProvider(),
                    "MintyNFT",
                    "MINTY",
                    "test token",
                    "1634822440",
                    "https://i.imgur.com/n7GdlOO.jpeg",
                    "https://i.imgur.com/n7GdlOO.jpeg"
            ).send();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
public class CustomerGasProvider extends StaticGasProvider {
    public static final BigInteger GAS_LIMIT = BigInteger.valueOf(10000000L);
    public static final BigInteger GAS_PRICE = BigInteger.valueOf(4000000000000L);

    public CustomerGasProvider() {
        super(GAS_PRICE, GAS_LIMIT);
    }
}

Contract:

https://pastebin.com/0hdqfa3g

Maybe there is a problem with the generated wrapper? Not sure

https://pastebin.com/vtuAzfBe

coffeemuggg commented 3 years ago

After whole day of debugging entire app I have figured out the issue :)) Generated wrapper code with the web3j cli gives returns json, but to sign the transaction successfully I needed only the byte code (not very clear in the docs unfortunately). Figured it out by checking the thetajs sourcecode. Can finally sign and create directly from android app :D

jieyilong commented 3 years ago

Good to hear you sorted it out! :)