The quickest way to start building on Ton 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 other popular programming languages.
Get Your Ton Endpoint
Ein Quicknode-Konto erstellen
Melde dich hier an, falls du das noch nicht getan hast.
Gehen Sie zu Ihrem Dashboard
Öffnen Sie das Endpunkte-Dashboard über das Menü in der linken Seitenleiste, um alle Ihre Blockchain-Endpunkte zu verwalten
Neuen Endpunkt erstellen
Click Create an Endpoint in the top-right corner, select Ton as your blockchain, then select your preferred network
Kopieren Sie die URLs Ihres Anbieters
Halten Sie die HTTP-URL griffbereit. Sie werden sie in den folgenden Anfragen verwenden.
Eine ausführliche Anleitung zur Nutzung des Quicknode-Dashboards finden Sie in unserem Leitfaden
Senden Sie Ihre erste Anfrage
Your endpoint is ready. Now, let's make your first call to the Ton blockchain. We'll use the getMasterchainInfo method, which retrieves masterchain information. Wählen Sie Ihre bevorzugte Sprache aus und befolgen Sie die nachstehenden Schritte, um Ihre erste Anfrage zu senden.
- cURL
- Node.js
Python
- Ruby
cURL-Installation überprüfen
Die meisten *nix-basierten Systeme unterstützen cURL standardmäßig. Öffnen Sie Ihr Terminal und überprüfen Sie die cURL-Version, indem Sie den folgenden Befehl ausführen:
curl --version
Send a GET request
In your terminal, copy and paste the following cURL command to retrieve the masterchain information:
curl --location 'YOUR_QUICKNODE_ENDPOINT_URL/getMasterchainInfo' \
--header 'accept: application/json'
Beispielantwort
{
"ok": true,
"result": {
"workchain": -1,
"shard": -9223372036854775808,
"seqno": 12345678,
"root_hash": "abc123...",
"file_hash": "def456..."
}
}
Richten Sie Ihr Projekt ein
Überprüfen Sie zunächst mit dem Befehl „node --version“, ob Node.js installiert ist. Falls nicht, laden Sie es unter https://nodejs.org herunter. Erstellen Sie anschließend ein neues Verzeichnis und initialisieren Sie ein Node.js-Projekt:
mkdir ton-api-quickstart
cd ton-api-quickstart
npm init -y
Create your script
Create a new file called index.js and add the following code to retrieve the masterchain information:
const https = require('https');
const options = {
hostname: '{your-endpoint-name}.quiknode.pro',
path: '/{your-token}/getMasterchainInfo',
method: 'GET',
headers: {
'accept': 'application/json'
}
};
const req = https.request(options, (res) => {
let result = '';
res.on('data', (chunk) => {
result += chunk;
});
res.on('end', () => {
console.log(result);
});
});
req.on('error', (error) => {
console.error('Error:', error);
});
req.end();
Führen Sie Ihr Skript aus
Execute your script in the terminal to retrieve the masterchain information:
node index.js
Richten Sie Ihr Projekt ein
First, verify Python is installed with python --version or python3 --version. Then create a new directory for your project:
mkdir ton-api-quickstart
cd ton-api-quickstart
Eine virtuelle Umgebung erstellen und aktivieren
Erstellen Sie eine virtuelle Umgebung zur Verwaltung von Abhängigkeiten:
python3 -m venv venv
source venv/bin/activate
Install dependencies
Installieren Sie die Bibliothek „requests“ zum Absenden von HTTP-Anfragen:
pip install Requests
Create your script
Create a new file called main.py and add the following code to retrieve the masterchain information:
import requests
url = "YOUR_QUICKNODE_ENDPOINT_URL/getMasterchainInfo"
headers = {
'accept': 'application/json'
}
response = requests.request("GET", url, headers=headers)
print(response.text)
Führen Sie Ihr Skript aus
Execute your script in the terminal to retrieve the masterchain information:
python main.py
Richten Sie Ihr Projekt ein
First, create a new directory for your project:
mkdir ton-api-quickstart
cd ton-api-quickstart
Ruby-Installation überprüfen
Überprüfen Sie, ob Ruby auf Ihrem System installiert ist. Falls nicht, installieren Sie es unter https://ruby-lang.org:
ruby --version
Create your script
Create a new file called main.rb and add the following code to retrieve the masterchain information:
require "uri"
require "net/http"
url = URI("YOUR_QUICKNODE_ENDPOINT_URL/getMasterchainInfo")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["accept"] = "application/json"
response = https.request(request)
puts response.read_body
Führen Sie Ihr Skript aus
Execute your script in the terminal to retrieve the masterchain information:
Ruby main.rb
Wenn Sie mehr über das Absenden von API-Anfragen erfahren möchten, sehen Sie sich unsere Anleitungen und Beispiel-Apps an.