The quickest way to start building on XRPL 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 XRPL Endpoint
Quicknode 계정 만들기
아직 가입하지 않으셨다면 여기에서 가입해 주세요.
대시보드로 이동하세요
왼쪽 사이드바 메뉴에서 ‘엔드포인트’ 대시보드를 열어 모든 블록체인 엔드포인트를 관리하세요
새 엔드포인트 생성
Click Create an Endpoint in the top-right corner, select XRPL as your blockchain, then select your preferred network
서비스 제공업체 URL을 복사하세요
HTTP URL을 잘 챙겨 두세요. 아래에서 요청을 보낼 때 이 URL을 사용하게 될 것입니다.
Quicknode 대시보드에 대한 자세한 사용 방법은 당사의 가이드를 확인해 주세요
첫 요청 보내기
Your endpoint is ready. Now, let's make your first call to the XRPL blockchain. We'll use the 수수료 method, which retrieves current fee information from the network. 원하는 언어를 선택하고 아래 단계를 따라 첫 번째 요청을 보내세요..
- cURL
- Node.js
파이썬
- 루비
cURL 설치 상태 확인
대부분의 *nix 기반 시스템은 기본적으로 cURL을 지원합니다. 터미널을 열고 아래 명령어를 실행하여 cURL 버전을 확인하세요:
curl --version
JSON-RPC 요청 보내기
In your terminal, copy and paste the following cURL command to retrieve current fee information:
curl YOUR_QUICKNODE_ENDPOINT_URL/ \
-X POST \
-H "Content-Type: application/json" \
--data '{
"method": "fee",
"params": [{}],
"id": 1,
"jsonrpc": "2.0"
}'
답변 예시
{
"id": 1,
"status": "success",
"type": "response",
"result": {
"current_ledger_size": "56",
"current_queue_size": "0",
"drops": {
"base_fee": "10",
"median_fee": "5000",
"minimum_fee": "10",
"open_ledger_fee": "10"
},
"expected_ledger_size": "55",
"ledger_current_index": 75708765,
"levels": {
"median_level": "128000",
"minimum_level": "256",
"open_ledger_level": "256",
"reference_level": "256"
},
"max_queue_size": "1100"
}
}
프로젝트 설정하기
먼저, `node --version` 명령어를 실행하여 Node.js가 설치되어 있는지 확인하세요. 설치되어 있지 않다면 https://nodejs.org에서 다운로드하세요. 그런 다음 새 디렉터리를 생성하고 Node.js 프로젝트를 초기화하세요:
mkdir xrpl-api-quickstart
cd xrpl-api-quickstart
npm init -y
메인 파일 만들기
코드를 담을 index.js 파일을 생성하세요:
touch index.js
이 코드를 index.js 파일에 추가하세요
이 코드를 복사하여 index.js 파일에 붙여넣으세요:
const https = require('https');
const data = JSON.stringify({
method: "fee",
params: [{}],
id: 1,
jsonrpc: "2.0"
});
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 responseData = '';
res.on('data', (chunk) => {
responseData += chunk;
});
res.on('end', () => {
console.log('XRPL Fee Information:');
console.log(JSON.stringify(JSON.parse(responseData), null, 2));
});
});
req.on('error', (error) => {
console.error('Error:', error);
});
req.write(data);
req.end();
스크립트를 실행하세요
Execute your Node.js script to retrieve fee information:
node index.js
프로젝트 설정하기
Create a new directory for your project:
mkdir xrpl-api-quickstart
cd xrpl-api-quickstart
가상 환경 생성 및 활성화
의존성을 관리하기 위한 가상 환경을 생성합니다:
python3 -m venv venv
source venv/bin/activate
Install required packages
Install the requests library:
pip 설치 requests
파이썬 스크립트(main.py)를 만드세요.
다음 코드가 포함된 main.py 파일을 생성하세요:
import requests
import json
url = "YOUR_QUICKNODE_ENDPOINT_URL/"
payload = {
"method": "fee",
"params": [{}],
"id": 1,
"jsonrpc": "2.0"
}
headers = {
'Content-Type': 'application/json'
}
try:
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
data = response.json()
print("XRPL Fee Information:")
print(json.dumps(data, indent=2))
except requests.exceptions.RequestException as e:
print(f"Error making request: {e}")
except json.JSONDecodeError as e:
print(f"Error parsing JSON: {e}")
스크립트를 실행하세요
Execute your Python script to retrieve fee information:
python main.py
프로젝트 설정하기
Ruby 프로젝트를 위한 새 디렉터리를 생성하세요:
mkdir xrpl-ruby-quickstart
cd xrpl-ruby-quickstart
Check Ruby Installation
시스템에 Ruby가 설치되어 있는지 확인하십시오. 설치되어 있지 않다면, https://ruby-lang.org에서 설치하십시오:
ruby --version
Ruby 스크립트(main.rb)를 만듭니다.
다음 코드가 포함된 main.rb 파일을 생성하세요:
require 'uri'
require 'net/http'
require 'json'
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 = {
method: "fee",
params: [{}],
id: 1,
jsonrpc: "2.0"
}.to_json
begin
response = https.request(request)
if response.is_a?(Net::HTTPSuccess)
data = JSON.parse(response.body)
puts 'XRPL Fee Information:'
puts JSON.pretty_generate(data)
else
puts "HTTP Error: #{response.code} - #{response.message}"
end
rescue JSON::ParserError => e
puts "JSON parsing error: #{e.message}"
rescue => e
puts "Error: #{e.message}"
end
스크립트를 실행하세요
Execute your Ruby script to retrieve fee information:
ruby main.rb
API 요청 방법에 대해 더 자세히 알아보고 싶으시다면, 당사의 가이드와 샘플 앱을 확인해 보세요.
여러분의 피드백을 ❤️ 환영합니다!
이 문서에 대한 의견이나 질문이 있으시면 언제든지 알려주세요. 여러분의 의견을 기다리고 있습니다!