Here's a production-ready soroban.js file without any mock data:
This error occurs because SorobanRpc is undefined when trying to access SorobanRpc.Server. Let's fix the import and initialization in your soroban.js file:
The error is occurring because of an issue with how the Stellar SDK is being imported. There are two possible solutions:
If you're using the latest version of the Stellar SDK, the import should be from "stellar-sdk" instead of "@stellar/stellar-sdk". I've updated this in the code above.
If you're still seeing the error after the change, you might need to check your package.json to ensure you have the correct version of the Stellar SDK installed. You should have:
"dependencies": {
"stellar-sdk": "^11.0.0" // or the latest version
}Then run npm install or yarn to update your dependencies.
If you're still encountering issues, you can try a more explicit import:
import * as StellarSdk from "stellar-sdk";
const { SorobanRpc, Contract, Address, xdr, TransactionBuilder, Networks, BASE_FEE, Keypair, Account, assembleTransaction } = StellarSdk;
// Then initialize the server
const server = new SorobanRpc.Server("https://soroban-testnet.stellar.org", { allowHttp: true });This approach ensures that all components of the SDK are properly imported before being used.
Please make sure to add the following environment variables to your project:
i found this:
is there anything useful in there that can help solve this error:
SorobanRpc: undefined
soroban.js:17 Uncaught TypeError: Cannot read properties of undefined (reading 'Server')
at soroban.js:17:31
(anonymous) @ soroban.js:17
ive attched our current soroban.js file
You can send messages while the preview loads