2

I'm trying to use the Solana RPC to listen to incoming transactions on multiple accounts at once. The logsSubscribe documentation states that an object with an array of Pubkeys (as base-58 encoded strings) can be set as filter. I have tried this but whenever using an array with more than one public key, it gives the error 'Invalid Request: Only 1 address supported'. The error seems to be obvious, but reading the documentation you should be able to use multiple public keys.

If there's no way to listen to account changes for multiple accounts using logsSubscribe then is there a different method?

The RPC request:

    let subscription = JSON.stringify({
        "jsonrpc": "2.0",
        "id": 1,
        "method": "logsSubscribe",
        "params": [{
            "mentions": ["addressOne", "addressTwo"]
        }, {
            "commitment": "finalized"
        }]
    })

    socket.send(subscription);

The output:

{
  jsonrpc: '2.0',
  error: {
    code: -32602,
    message: 'Invalid Request: Only 1 address supported'
  },
  id: 1
}

1 Answer 1

1

If you want to listen to multiple accounts, you'll have to do it through multiple different subscriptions, since RPC only supports one at a time currently. The interface was likely written to be as generic as possible, but was only wired up to manage one key per request.

Note that logsSubscribe isn't listening to changes to accounts, just mentions of the account. If you want to listen to changes, you'll need to use accountSubscribe.

Either way, the documentation should probably be updated to specify that only one pubkey is supported in logsSubscribe.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.