The quickest way to start building on Zcash 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 Zcash 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 Zcash 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 Zcash blockchain. We'll use the getblock method, which retrieves detailed information about a specific block by its hash. Wählen Sie Ihre bevorzugte Sprache oder Ihr SDK aus und befolgen Sie die nachstehenden Schritte, um Ihre erste Anfrage zu senden.
- cURL
Python
- JavaScript
- 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
Eine JSON-RPC-Anfrage senden
In your terminal, copy and paste the following cURL command to retrieve block information:
curl YOUR_QUICKNODE_ENDPOINT_URL/ \
-X POST \
-H "Content-Type: application/json" \
--data '{"id": 1, "jsonrpc": "2.0", "method": "getblock", "params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"]}'
Beispielantwort
{
"result": {
"hash": "00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09",
"confirmations": 912736,
"size": 216,
"height": 1000,
"version": 1,
"versionHex": "00000001",
"merkleroot": "fe28050b93faea61fa88c4c630f0e1f0a1c24d0082dd0e10d369e13212128f33",
"tx": [
"fe28050b93faea61fa88c4c630f0e1f0a1c24d0082dd0e10d369e13212128f33"
],
"time": 1232346882,
"mediantime": 1232344831,
"nonce": 2595206198,
"bits": "1d00ffff",
"difficulty": 1,
"chainwork": "000000000000000000000000000000000000000000000000000003e903e903e9",
"nTx": 1,
"previousblockhash": "0000000008e647742775a230787d66fdf92c46a48c896bfbc85cdc8acc67e87d",
"nextblockhash": "00000000a2887344f8db859e372e7e4bc26b23b9de340f725afbf2edb265b4c6"
},
"error": null,
"id": 1
}
Richten Sie Ihr Projekt ein
Erstellen Sie ein neues Verzeichnis für Ihr Python-Projekt:
mkdir zcash-python-quickstart
cd zcash-python-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
Installationsanfragen
Installieren Sie die Bibliothek „requests“ zum Absenden von HTTP-Anfragen:
pip install Requests
Erstellen Sie ein Python-Skript (app.py)
Erstellen Sie eine Python-Datei mit dem folgenden Code:
import requests
import json
# Your Quicknode endpoint URL
url = "YOUR_QUICKNODE_ENDPOINT_URL/"
# JSON-RPC request payload for getblock
payload = json.dumps({
"id": 1,
"jsonrpc": "2.0",
"method": "getblock",
"params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"]
})
headers = {
'Content-Type': 'application/json'
}
# Make the request
response = requests.request("POST", url, headers=headers, data=payload)
result = response.json()
print("Block information:")
print(json.dumps(result, indent=2))
Führen Sie das Skript aus
Führen Sie Ihr Python-Skript aus:
python app.py
Richten Sie Ihr Projekt ein
Erstellen Sie ein neues Verzeichnis und initialisieren Sie ein Node.js-Projekt:
mkdir zcash-js-quickstart
cd zcash-js-quickstart
npm init -y
Erstellen Sie eine JavaScript-Datei (app.js)
Create an app.js file with the following code (using native https module):
const https = require('https');
// Your Quicknode endpoint URL
const data = JSON.stringify({
"id": 1,
"jsonrpc": "2.0",
"method": "getblock",
"params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"]
});
const options = {
hostname: '{your-endpoint-name}.quiknode.pro',
path: '/{your-token}/',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length
}
};
const req = https.request(options, (res) => {
let result = '';
res.on('data', (chunk) => {
result += chunk;
});
res.on('end', () => {
console.log('Block information:');
console.log(JSON.parse(result));
});
});
req.on('error', (error) => {
console.error('Error:', error);
});
req.write(data);
req.end();
Führen Sie das Skript aus
Führen Sie Ihr JavaScript-Skript aus:
Knoten app.js
Richten Sie Ihr Projekt ein
Erstellen Sie ein neues Verzeichnis für Ihr Ruby-Projekt:
mkdir zcash-ruby-quickstart
cd zcash-ruby-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
Erstellen Sie ein Ruby-Skript (main.rb)
Erstellen Sie eine Datei „main.rb“ mit dem folgenden Code:
require "uri"
require "json"
require "net/http"
# Your Quicknode endpoint URL
url = URI("YOUR_QUICKNODE_ENDPOINT_URL/")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"id": 1,
"jsonrpc": "2.0",
"method": "getblock",
"params": ["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"]
})
response = https.request(request)
result = JSON.parse(response.read_body)
puts "Block information:"
puts JSON.pretty_generate(result)
Führen Sie das Skript aus
Execute your Ruby script to retrieve block 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.
Wir ❤️ Feedback!
Wenn Sie Anregungen oder Fragen zu dieser Dokumentation haben, teilen Sie uns diese bitte mit. Wir freuen uns auf Ihre Rückmeldung!