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
Create a Quicknode account
Sign up here if you haven't already.
Go to your dashboard
Open the Endpoints dashboard from the left sidebar menu to manage all your blockchain endpoints
Create a new endpoint
Click Create an Endpoint in the top-right corner, select Ton as your blockchain, then select your preferred network
Copy your provider URLs
Keep the HTTP URL handy. You'll use it in your requests below.
For a detailed walkthrough of the Quicknode dashboard, check out our guide
Send Your First Request
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. Select your preferred language and follow the steps below to send your first request.
- cURL
- Node.js
- Python
- Ruby
Check cURL installation
Most *nix based systems have cURL support out of the box. Open your terminal and check the cURL version by running the command below:
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'
Sample Response
{
"ok": true,
"result": {
"workchain": -1,
"shard": -9223372036854775808,
"seqno": 12345678,
"root_hash": "abc123...",
"file_hash": "def456..."
}
}
Set up your project
First, verify Node.js is installed with node --version. If not installed, download it from https://nodejs.org. Then create a new directory and initialize a Node.js project:
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();
Run your script
Execute your script in the terminal to retrieve the masterchain information:
node index.js
Set up your project
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
Create and activate a virtual environment
Create a virtual environment to manage dependencies:
python3 -m venv venv
source venv/bin/activate
Install dependencies
Install the requests library for making HTTP requests:
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)
Run your script
Execute your script in the terminal to retrieve the masterchain information:
python main.py
Set up your project
First, create a new directory for your project:
mkdir ton-api-quickstart
cd ton-api-quickstart
Check Ruby installation
Verify Ruby is installed on your system. If not, install it from 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
Run your script
Execute your script in the terminal to retrieve the masterchain information:
ruby main.rb
If you want to continue learning about making API requests, check out our guides and sample apps.
We ❤️ Feedback!
If you have any feedback or questions about this documentation, let us know. We'd love to hear from you!