The Network Payments CLI provides a streamlined command-line interface for interacting with The Graph Network's Payments API. Its primary goal is to simplify sending and receiving payments on the network.
To install the CLI tools:
git clone [email protected]:streamingfast/network-payments-cli.git
cd network-payments-cli
go install ./cmd/...
This will install two commands:
sendpayment
receivepayment
The typical flow involves three main steps:
- Open an allocation: The payment receiver opens an allocation on The Graph network using
receivepayment open-allocation
and shares the allocation ID with the sender. - Send payment: The payment sender transfers funds to the allocation using
sendpayment
. - Close the allocation: The payment receiver closes the allocation using
receivepayment close-allocation
.
-
Stake Ratio:
As per GIP-0051 on Exponential Rebates, indexers should maintain a stake ratio of at least 10:1 (stake to query fees). Ensure this ratio is adhered to as it may change based on network parameters. -
Query Fee Cut:
The indexer's Query Fee Cut percentage affects the total amount received. For example, a 70% Query Fee Cut means the indexer keeps 70% of the payment. Ensure this percentage is correctly set. -
Network Tax:
A 1% network tax applies to all payments, reducing the allocation amount by 1% before it reaches the indexer.
The payment receiver opens an allocation for 100 GRT:
receivepayment open-allocation \
--allocation-amount {amount of GRT to allocate} \
--indexer-address {address of the indexer receiving the payment} \
--private-key-file {path-to-private-key-file} \
--rpc-url http://{arbitrum-rpc-endpoint}
This will return the deployment ID
and allocation ID
, which should be shared with the payment sender.
The payment sender sends 10 GRT to the allocation:
sendpayment \
--allocation-id {allocation-id from step 1} \
--deployment-id {deploymet-id from step 1} \
--private-key-file {path-to-private-key-file} \
--rpc-url http://{arbitrum-rpc-endpoint} \
--amount {amount of GRT to send}
The payment receiver closes the allocation:
receivepayment close-allocation \
--allocation-id {{allocation-id from step 1}} \
--deployment-id {deploymet-id from step 1} \
--private-key-file {path-to-private-key-file} \
--rpc-url http://{arbitrum-rpc-endpoint}
Notes:
- Ensure the private key corresponds to the indexer receiving the payment.
ARBITRUM_RPC_URL
: RPC URL for interacting with the Arbitrum network. This can replace the--rpc-url
flag.NETWORK_PAYMENT_PRIVATE_KEY
: Hex-encoded private key for signing transactions. This can replace the--private-key-file
flag.
-
Common Errors:
- Incorrect allocation ID: Verify the allocation ID provided by the receiver.
- RPC URL issues: Ensure the correct Arbitrum RPC URL is configured.
- Private key errors: Confirm the private key file path or environment variable is set correctly.
-
Debugging: Use verbose logging by appending
--log-level debug
to commands.