The quickest way to start building on Solana with Quicknode is by sending a JSON-RPC request to your endpoint. In this quickstart, you’ll create an endpoint, copy its provider URL, and make your first request. Code samples are available in cURL as well as popular SDKs and programming languages.
Get Your Solana Endpoint
Criar uma conta no Quicknode
Inscreve-te aqui, se ainda não o fizeste.
Aceda ao seu painel de controlo
Abra o painel «Endpoints» a partir do menu da barra lateral esquerda para gerir todos os seus endpoints de blockchain
Criar um novo ponto de extremidade
Click Create an Endpoint in the top-right corner, select Solana as your blockchain, then select your preferred network
Copie os URLs do seu fornecedor
Tenha a URL HTTP à mão. Vai precisar dela nas solicitações que vai fazer a seguir.
Para um guia detalhado do painel do Quicknode, consulte o nosso guia
Envie o seu primeiro pedido
Your endpoint is ready. Now, let's make your first call to the Solana blockchain. We’ll use the getSlot method, which returns the slot number. Selecione o seu idioma ou SDK preferido e siga os passos abaixo para enviar o seu primeiro pedido.
- cURL
- Solana Kit (@solana/kit)
- Solana-Web3.js
Solana.py
- Solana CLI
Get Slot
To run the cURL request, open a terminal window and paste the following code to retrieve the current slot.
curl 'YOUR_QUICKNODE_ENDPOINT_URL/' \
-X POST \
-H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","id":1, "method":"getSlot"}'
Configure o seu projeto
Crie um novo diretório e inicialize um projeto Node.js (partindo do princípio de que o Node.js já está instalado):
mkdir solana-quickstart
cd solana-quickstart
npm init -y
Install Solana Kit
Install the Solana Kit SDK for blockchain interaction:
npm install --save @solana/kit
Crie o seu ficheiro principal
Create an index.ts file with the following code:
import { createSolanaRpc } from "@solana/kit";
(async () => {
const solanaRpc = createSolanaRpc("YOUR_QUICKNODE_ENDPOINT_URL/");
try {
const slot = await solanaRpc.getSlot().send();
console.log(slot);
} catch (error) {
console.error("Error fetching slot:", error);
}
})();
Execute o seu projeto
Execute your script to see the current slot:
npx tsx index.ts
Configure o seu projeto
Crie um novo diretório e inicialize um projeto Node.js (partindo do princípio de que o Node.js já está instalado):
mkdir solana-quickstart
cd solana-quickstart
npm init -y
Install Solana Web3.js SDK
Install the Solana JavaScript SDK for blockchain interaction:
npm install --save @solana/web3.js
Crie o seu ficheiro principal
Crie um ficheiro index.js com o seguinte código:
const web3 = require("@solana/web3.js");
(async () => {
const solana = new web3.Connection("YOUR_QUICKNODE_ENDPOINT_URL/");
const slot = await solana.getSlot();
console.log('Current slot:', slot);
})();
Execute o seu projeto
Execute your script to see the current slot number:
node index.js
Configure o seu projeto
Create a new directory for your Solana Python project:
mkdir solana-python-quickstart
cd solana-python-quickstart
Install Solana.py (if not already installed)
Check if solana is installed with `pip list | grep solana`. If not found, install it:
pip install solana cachetools
Create and run Python script
Create an app.py file with the following code, then execute it with `python app.py` to retrieve the current slot number:
from solana.rpc.api import Client
solana_client = Client("YOUR_QUICKNODE_ENDPOINT_URL/")
slot_response = solana_client.get_slot()
print(f"Current slot: {slot_response.value}")
Get current slot
solana slot --url YOUR_QUICKNODE_ENDPOINT_URL/
Se quiseres continuar a aprender sobre como efetuar pedidos à API, consulta os nossos guias e aplicações de exemplo.
Adoramos ❤️ os vossos comentários!
Se tiver algum comentário ou dúvida sobre esta documentação, não hesite em contactar-nos. Adoraríamos saber a sua opinião!