Coder Social home page Coder Social logo

Comments (7)

xJonathanLEI avatar xJonathanLEI commented on June 1, 2024 1

Hey guys I'm here because @irisdv opened xJonathanLEI/starknet-rs#508 on starknet-rs.

@yair-starkware I'm afraid that's not correct according to the specs. The spec says there are 2 params: request and block_id.

JSON-RPC allows params to be named or positional. For them to be positional:

[
  {
    "contract_address": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
    "entry_point_selector": "0x2e4263afad30923c891518314c3c95dbe830a16874e8abc5777a9a20b54c76e",
    "calldata": [
      "0x061b6c0a78f9edf13cea17b50719f3344533fadd470b8cb29c2b4318014f52d3"
    ]
  },
  "latest"
]

and for them to be named:

{
  "request": {
    "contract_address": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
    "entry_point_selector": "0x2e4263afad30923c891518314c3c95dbe830a16874e8abc5777a9a20b54c76e",
    "calldata": [
      "0x061b6c0a78f9edf13cea17b50719f3344533fadd470b8cb29c2b4318014f52d3"
    ]
  },
  "block_id": "latest"
}

The structure expected by Papyrus is neither of these two. Papyrus is not compliant with the specs here.

from papyrus.

Th0rgal avatar Th0rgal commented on June 1, 2024

Hey, I am adding a simple curl example so you can reproduce it. With my alchemy RPC endpoint, I can do:

❯ curl --location 'https://starknet-goerli.g.alchemy.com/v2/MY_ALCHEMY_KEY' \
--header 'Content-Type: application/json' \
--data '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "starknet_call",
    "params": [
        {
            "contract_address": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
            "entry_point_selector": "0x2e4263afad30923c891518314c3c95dbe830a16874e8abc5777a9a20b54c76e",
            "calldata": ["0x061b6c0a78f9edf13cea17b50719f3344533fadd470b8cb29c2b4318014f52d3"]
        },
        "latest"
    ]
}'

Which returns:

{"jsonrpc":"2.0","result":["0x9c51c4521e0000","0x0"],"id":1}

When trying this with my endpoint, it unfortunately doesn't work (using /rpc/v0_5 and /rpc/v0_4):

❯ curl --location 'https://goerli.rpc.starknet.id/rpc/v0_5' \
--header 'Content-Type: application/json' \
--data '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "starknet_call",
    "params": [
        {
            "contract_address": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
            "entry_point_selector": "0x2e4263afad30923c891518314c3c95dbe830a16874e8abc5777a9a20b54c76e",
            "calldata": ["0x061b6c0a78f9edf13cea17b50719f3344533fadd470b8cb29c2b4318014f52d3"]
        },
        "latest"
    ]
}'

I get:

{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params","data":"invalid type: map, expected a string at line 2 column 8"},"id":1}

from papyrus.

yair-starkware avatar yair-starkware commented on June 1, 2024

Hi,
Here is a valid curl cmd:

curl --location 'https://goerli.rpc.starknet.id/rpc/v0_5' --header 'Content-Type: application/json' --data '{
    "jsonrpc": "2.0",
    "id": 0,
    "method": "starknet_call",
    "params": {
        "contract_address": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
        "entry_point_selector": "0x2e4263afad30923c891518314c3c95dbe830a16874e8abc5777a9a20b54c76e",
        "calldata": ["0x061b6c0a78f9edf13cea17b50719f3344533fadd470b8cb29c2b4318014f52d3"],
        "block_id": "latest"
    }    
}'  

from papyrus.

ManutdGTA avatar ManutdGTA commented on June 1, 2024

same issue in starknet.py,I have asked for help in papyrus channel in discord,but noone answered
line 122, in _get_balance\n'
' balance = await account.get_balance(\n'
low, high = await self._client.call_contract(\n'
res = await self._client.call(\n'
self.handle_rpc_error(result)\n'
raise ClientError(\n'
'starknet_py.net.client_errors.ClientError: Client failed with code -32602: '
'Invalid params.\n'
Using alchemy or infura is okay, but Papyrus went wrong

# this is correct
client = FullNodeClient('https://starknet-mainnet.g.alchemy.com/v2/..')


# this went wrong
node_url = 'http://ip:8080/rpc/v0_5_0'
client = FullNodeClient(node_url)


account = get_account(wallet.private_key, wallet.address)
balance = await get_balance(account, starknet_usdc_address)
usdc_balance_readable = balance / 1e6
print(f"USDC balance:{usdc_balance_readable}")

papyrus serve is running normal
ubuntu@server:~$ curl --location 'http://localhost:8080/rpc/v0_5_0' --header 'Content-Type: application/json' --data-raw '{"jsonrpc":"2.0","id":0,"method":"starknet_blockHashAndNumber"}'
{"jsonrpc":"2.0","result":{"block_hash":"0x7f60cfed49727d4288068234704cd18e09386cb87f54fb12b51b213901c7a74","block_number":458230},"id":0}

I checked starknet_getStorageAt and starknet_getClass is ok
but methods 'starknet_call' went wrong
http_method HttpMethod.POST
address http://ip:8080/rpc/v0_4_0
payload {'jsonrpc': '2.0', 'method': 'starknet_call', 'params': {'request': {'contract_address': '...', 'entry_point_selector': '...', 'calldata': ['..']}, 'block_id': 'pending'}, 'id': 0}
the params r all the same ,but it went wrong
ubuntu@server:~$ curl --location 'http://localhost:8080/rpc/v0_5_0' --header 'Content-Type: application/json' --data-raw '{"jsonrpc": "2.0","method": "starknet_call","params": {"request":{"contract_address":"...","entry_point_selector":"...","calldata":["..."]},"block_id":"pending"},"id":0}'
curl: (52) Empty reply from server

from papyrus.

dan-starkware avatar dan-starkware commented on June 1, 2024

Thanks for pointing it out! We'll fix it.

from papyrus.

ManutdGTA avatar ManutdGTA commented on June 1, 2024

Thanks for pointing it out! We'll fix it.

hello, it has been a month

from papyrus.

github-actions avatar github-actions commented on June 1, 2024

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a 👍
Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs.
Thank you for your contributions!

from papyrus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.