Skip to content

Compatibility with another mpp #24

@Se76

Description

@Se76

Motivation:

curl --request POST \
  --url https://mpp.quicknode.com/solana-mainnet \
  --header 'Content-Type: application/json' \
  --data '{"jsonrpc":"2.0","id":1,"method":"getSignaturesForAddress","params":["CzzWWaQtz8oCcEPiRi1ziz9djWqYf7WgZK9rtbJSMEef",{"limit":10}]}'

then the response header was containing eyJhbW91bnQiOiIwLjAwMSIsImN1cnJlbmN5IjoiRVBqRldkZDVBdWZxU1NxZU0ycU4xeHp5YmFwQzhHNHdFR0drWnd5VER0MXYiLCJtZXRob2REZXRhaWxzIjp7ImRlY2ltYWxzIjo2LCJtaW50IjoiRVBqRldkZDVBdWZxU1NxZU0ycU4xeHp5YmFwQzhHNHdFR0drWnd5VER0MXYiLCJuZXR3b3JrIjoibWFpbm5ldC1iZXRhIiwicmVjaXBpZW50IjoiNmJNWkRHYVdMb0pFVkN3UzZSQ05hcWZTM1VpcHFHMmQ2bVVORXFwNktRWjUiLCJyZWZlcmVuY2UiOiJCdVlHZkVhcXFHZUJXYzVldzJFZjZYRWJSaG9mNzF6Z1lZOGpGdlUxNWNxcyJ9fQ ->

{"amount":"0.001","currency":"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","methodDetails":{"decimals":6,"mint":"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","network":"mainnet-beta","recipient":"6bMZDGaWLoJEVCwS6RCNaqfS3UipqG2d6mUNEqp6KQZ5","reference":"BuYGfEaqqGeBWc5ew2Ef6XEbRhof71zgYY8jFvU15cqs"}}

Normally it would have contain "amount":"1000" because USDC token has 6 decimals. The entire problem is because quicknode is using another solana mpp implementation (https://www.quicknode.com/docs/build-with-ai/mpp-payments), but independently of it, I want for my agent to be able to pay for all by simply using official mpp, without worrying about support for another mpp.

The main problem was that the @solana/mpp client called BigInt(amount) directly on the challenge amount string. When a server sends a human-readable decimal like "0.001" instead of atomic units like "1000", BigInt("0.001") throws a SyntaxError, making the payment fail entirely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions