Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

EthereumTransaction.ContractGeneric example #103

Closed
codeandgraphics opened this issue Jul 8, 2021 · 1 comment
Closed

EthereumTransaction.ContractGeneric example #103

codeandgraphics opened this issue Jul 8, 2021 · 1 comment

Comments

@codeandgraphics
Copy link

Hello!

Trying to sign eth contract method call with TrustSDK/WalletCore, then try to sign this data with sdk_sign URL Scheme. TrustWallet responds with the sign_error. Any example of how we can sign a contract call correctly?

    let signerInput = EthereumSigningInput.with {
      $0.toAddress = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"
      $0.chainID = BigInt("1").serialize()!
      $0.nonce = BigInt("477").serialize()!
      $0.gasPrice = BigInt("2112000000").serialize()!
      $0.gasLimit = BigInt("21000").serialize()!
      $0.privateKey = wallet.getKeyForCoin(coin: .ethereum).data
      $0.transaction = EthereumTransaction.with {
        $0.contractGeneric = EthereumTransaction.ContractGeneric.with {
          $0.data = Data(hexString:"ad5c4648")!
          $0.amount = BigInt("0").serialize()!
        }
      }
    }

If we use erc20 transfer – it's all ok, but no success with ContractGeneric.

@ArtemGoryunov
Copy link
Contributor

Try this one

    let signerInput = EthereumSigningInput.with {
      $0.toAddress = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"
      $0.chainID = BigInt("1").serialize()!
      $0.nonce = BigInt("477").serialize()!
      $0.gasPrice = BigInt("2112000000").serialize()!
      $0.gasLimit = BigInt("21000").serialize()!
      $0.privateKey = wallet.getKeyForCoin(coin: .ethereum).data
      $0.transaction = EthereumTransaction.with {
        $0.transactionOneof = EthereumTransaction.ContractGeneric.with {
          $0.data = Data(hexString:"ad5c4648")!
          $0.amount = BigInt("0").serialize()!
        }
      }
    }

@vikmeup vikmeup closed this as completed Aug 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants