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

Data slice parameters for getAccountInfo #983

Closed
leofisG opened this issue Aug 28, 2020 · 3 comments
Closed

Data slice parameters for getAccountInfo #983

leofisG opened this issue Aug 28, 2020 · 3 comments

Comments

@leofisG
Copy link

leofisG commented Aug 28, 2020

According to the JSON RPC documentation here, it has an optional parameter dataSlice however this doesn't seem to be present in the web3 client. So I am wondering is this not implemented?

If so, how do we send the request with the dataSlice parameter using curl?

I am looking for something similar to:

// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"getAccountInfo", "params":["vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",{"encoding": "base58"}]}' http://localhost:8899

Thanks!

@CriesofCarrots
Copy link
Contributor

CriesofCarrots commented Aug 28, 2020

Here's a working example on mainnet-beta using dataSlice:

// Request
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"getAccountInfo", "params":["Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo",{"encoding":"base64", "dataSlice":{"offset":0,"length":8}}]}' api.mainnet-beta.solana.com

// Response
{"jsonrpc":"2.0","result":{"context":{"slot":31173838},"value":{"data":["f0VMRgIBAQA=","base64"],"executable":true,"lamports":121159680,"owner":"BPFLoader1111111111111111111111111111111111","rentEpoch":41}},"id":1}

I discovered there's a small bug using base58 encoding; if the account data is larger than 128 bytes, the request won't return, even if the requested slice is smaller than 128 bytes. But should work for small accounts, or base64 works for all accounts.

@steveluscher
Copy link
Collaborator

This was added in solana-labs/solana#28389.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2023

Because there has been no activity on this issue for 7 days since it was closed, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2023
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