Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the storage of specified address and slot when call debug_traceBlockByNumber with custom js tracer? #30819

Open
rekyyang opened this issue Nov 27, 2024 · 1 comment

Comments

@rekyyang
Copy link

rekyyang commented Nov 27, 2024

For some reason, I want to get the storage of specified address and slot when I trace blocks with custom js tracer(in step function). I tried to pass the string like '0x0000000.....0000' as the input params of db.getState, but the node return the error msg as invalid buffer type at step, so I want to know how to build the js-tracer to record and return the storage of specified address and slot.

this is my failed attemp:

curl --location 'http://localhost:8545' \
--header 'Content-Type: application/json' \
--data '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "debug_traceBlockByNumber",
    "params": [
        "latest",
        {
            "tracer": "{retVal:[],step:function(log,db){this.retVal.push(db.getState(0x6f82d895e223dde65da28a8bbd14f3ef79cbf3b8,0x00000000000000000000000000000000000000000000000000000000000000cd))},fault:function(log,db){this.retVal.push('\''FAULT: '\''+JSON.stringify(log))},result:function(ctx,db){return this.retVal}}"
        }
    ]
}'

the error msg is:

{.........error":"invalid buffer type at step (\u003ceval\u003e:1:51(10))    in server-side tracer function 'step'"......}

the chain is Sepolia

@s1na
Copy link
Contributor

s1na commented Nov 28, 2024

You're missing quotation marks around the hex strings. Try if that fixes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants