question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"APIRequest.sendRequest()" doesn't work with erc1155ABI

See original GitHub issue

What happened?

This is when I tried to send tokens using ERC1155.

I generated the signed transaction using the ERC1155ABI. This is a decoded version of that transaction using https://flightwallet.github.io/decode-eth-tx/.

{
  "nonce": 0,
  "gasPrice": 124135355866,
  "gasLimit": 82646,
  "to": "0x29533991~",
  "value": 0,
  "data": "f242432a0000000000000000000000002953399124f0cbb46d2cbacd8a89cf0599974963000000000000000000000000713956a23~~~~~~a0000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000",
  "from": "0xe86cf02b510a238046479~",
  "r": "~",
  "v": "~",
  "s": "~"
}

And this is a decoded version of the “data” using https://lab.miguelmota.com/ethereum-input-data-decoder/example/

{
  "method": "safeTransferFrom",
  "types": [
    "address",
    "address",
    "uint256",
    "uint256",
    "bytes"
  ],
  "inputs": [
    "~~",
    "~",
    {
      "type": "BigNumber",
      "hex": "0x193d~~"

    },
    {
      "type": "BigNumber",
      "hex": "0x0a"
    },
    "0x"
  ],
  "names": [
    "from",
    "to",
    "id",
    "amount",
    "data"
  ]
}

At first glance, there seems to be no mistake. However, when I use “APIRequest.sendRequest()” for this transaction, I get an error

let request: APIRequest = .sendRawTransaction(tx)
let response: APIResponse<Hash> = try await APIRequest.sendRequest(with: web3.provider, for: request)

The error message is here.

Swift.DecodingError.keyNotFound(CodingKeys(stringValue: "result", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"result\", intValue: nil) (\"result\").", underlyingError: nil))

What are the steps to reproduce?

Step1 : Please create a transaction first.

contract.createWriteOperation("safeTransferFrom", parameters: [originalOwner, to, id, value, data] as [AnyObject] )

Step2:Please sign the transaction

Web3Signer.signTX(transaction: &writeOp.transaction,
                                  keystore: web3.provider.attachedKeystoreManager!,
                                  account: self.address! ,
                                  password: "")

Step3 Write that transaction into the chain.

let request: APIRequest = .sendRawTransaction(tx)
let response: APIResponse<Hash> = try await APIRequest.sendRequest(with: web3.provider, for: request)

What is the expected behavior?

If the transfer is successful, a hash of the transaction should be returned.

What is the error thrown?

Swift.DecodingError.keyNotFound(CodingKeys(stringValue: “result”, intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: “No value associated with key CodingKeys(stringValue: "result", intValue: nil) ("result").”, underlyingError: nil))

What’s the stack trace said?

Sources/Core/EthereumNetwork/Request/APIRequest+Methods

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
yaroslavyaroslavcommented, Nov 16, 2022

@zuv55 unfortunately ERC specs are not the best part of me, so I really don’t know.

1reaction
yaroslavyaroslavcommented, Nov 14, 2022

Got you, but please fill new issue for that to avoid messing up with different topics within one issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Could not get any response" on all my api calls #3127 - GitHub
If you get a Could not get any response message from Postman native apps while sending your request, open Postman Console (View >...
Read more >
How do you know what's gone wrong when your API request ...
When an API request doesn't work, hopefully the client receives a sensible HTTP error status, like 409 or 500, which is a good...
Read more >
REST POST Request not working - Stack Overflow
Here is my WCF Rest Api which is using POST. [OperationContract] [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat = ...
Read more >
Does anyone know why this post request doesn't work? I tried ...
I tried posting to the same API using Python and it worked, I have no clue why it isn't working in JS.
Read more >
ERC1155 - OpenZeppelin Docs
We'll use ERC1155 to track multiple items in our game, which will each have their own unique attributes. We mint all items to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found