I am using anchor 0.16.2, and following typescript packages
"@project-serum/anchor": "^0.16.2",
"@solana/spl-token": "^0.1.8",
"dotenv": "^10.0.0",
"yargs": "^16.2.0"
I set my solana config to the following variables
$ solana config get
Config File: /Users/raven/.config/solana/cli/config.yml
RPC URL: https://api.devnet.solana.com
WebSocket URL: wss://api.devnet.solana.com/ (computed)
Keypair Path: /Users/raven/.config/solana/id.json
Commitment: confirmed
and am invoking the following code
ANCHOR_PROVIDER_URL="https://api.devnet.solana.com" ANCHOR_WALLET=/Users/raven/.config/solana/id.json npm run serve
to run an expressJS server (typescript).
whenever I make an API call through the following code
const provider = anchor.getProvider()
const poolSigner = _poolSigner;
const currentBid = await getTokenAccount(provider, userRedeemable)
await exchangeUsdcForRedeemableRpc(
poolAccount,
poolSigner,
provider.wallet.publicKey,
userUsdc,
account.redeemableMint,
userRedeemable,
account.poolUsdc,
depositAmount,
);
I get an error
Error making the bidding request!
{}
Error: failed to get info about account AfQRhis7aZg6NmPpjrFN1KpZviMEp6H1VnKBzHkBxckK: FetchError: request to http://localhost:8899/ failed, reason: connect ECONNREFUSED 127.0.0.1:8899
at Connection.getAccountInfo (/Users/raven/imo-launchpad/example-server/node_modules/@solana/web3.js/src/connection.ts:2443:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async AccountClient.fetchNullable (/Users/raven/imo-launchpad/example-server/node_modules/@project-serum/anchor/src/program/namespace/account.ts:128:25)
at async AccountClient.fetch (/Users/raven/imo-launchpad/example-server/node_modules/@project-serum/anchor/src/program/namespace/account.ts:152:18)
In short: The request is made to the local testnet, instead of to devnet / the development cluster.
I find this weird, as in all instances that I could do, I have made sure to set the Solana cluster to https://api.devnet.solana.com
.
When I control-F the entire project, I only see the following code-snippet to include localhost:8899
as the link
static local(url?: string, opts?: ConfirmOptions): Provider {
opts = opts ?? Provider.defaultOptions();
const connection = new Connection(
url ?? "http://localhost:8899",
opts.preflightCommitment
);
const wallet = NodeWallet.local();
return new Provider(connection, wallet, opts);
}
manualy changing this in the node_modules
did not resolve this, however.
Is there anything wrong that I do, or anything I'm missing? The request is made to the local testnet, instead of to devnet / the development cluster.
Any help would be greatly appreciated, this is the last bug that stands between me and devnet.
This is for the ignition hackathon in 2 days, so I would appreciate any help a lot! :)