Transfer SPL Tokens
curl --request POST \
--url https://payments.magicblock.app/v1/spl/transfer \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"from": "3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE",
"to": "Bt9oNR5cCtnfuMmXgWELd6q5i974PdEMQDUE55nBC57L",
"mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"amount": 1000000,
"visibility": "private",
"fromBalance": "base",
"toBalance": "base",
"exactOut": false,
"initIfMissing": true,
"initAtasIfMissing": true,
"initVaultIfMissing": false,
"memo": "Order #1042",
"minDelayMs": "0",
"maxDelayMs": "0",
"clientRefId": "42",
"split": 1,
"gasless": true
}
'import requests
url = "https://payments.magicblock.app/v1/spl/transfer"
payload = {
"from": "3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE",
"to": "Bt9oNR5cCtnfuMmXgWELd6q5i974PdEMQDUE55nBC57L",
"mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"amount": 1000000,
"visibility": "private",
"fromBalance": "base",
"toBalance": "base",
"exactOut": False,
"initIfMissing": True,
"initAtasIfMissing": True,
"initVaultIfMissing": False,
"memo": "Order #1042",
"minDelayMs": "0",
"maxDelayMs": "0",
"clientRefId": "42",
"split": 1,
"gasless": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from: '3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE',
to: 'Bt9oNR5cCtnfuMmXgWELd6q5i974PdEMQDUE55nBC57L',
mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
amount: 1000000,
visibility: 'private',
fromBalance: 'base',
toBalance: 'base',
exactOut: false,
initIfMissing: true,
initAtasIfMissing: true,
initVaultIfMissing: false,
memo: 'Order #1042',
minDelayMs: '0',
maxDelayMs: '0',
clientRefId: '42',
split: 1,
gasless: true
})
};
fetch('https://payments.magicblock.app/v1/spl/transfer', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://payments.magicblock.app/v1/spl/transfer",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'from' => '3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE',
'to' => 'Bt9oNR5cCtnfuMmXgWELd6q5i974PdEMQDUE55nBC57L',
'mint' => 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
'amount' => 1000000,
'visibility' => 'private',
'fromBalance' => 'base',
'toBalance' => 'base',
'exactOut' => false,
'initIfMissing' => true,
'initAtasIfMissing' => true,
'initVaultIfMissing' => false,
'memo' => 'Order #1042',
'minDelayMs' => '0',
'maxDelayMs' => '0',
'clientRefId' => '42',
'split' => 1,
'gasless' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://payments.magicblock.app/v1/spl/transfer"
payload := strings.NewReader("{\n \"from\": \"3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE\",\n \"to\": \"Bt9oNR5cCtnfuMmXgWELd6q5i974PdEMQDUE55nBC57L\",\n \"mint\": \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n \"amount\": 1000000,\n \"visibility\": \"private\",\n \"fromBalance\": \"base\",\n \"toBalance\": \"base\",\n \"exactOut\": false,\n \"initIfMissing\": true,\n \"initAtasIfMissing\": true,\n \"initVaultIfMissing\": false,\n \"memo\": \"Order #1042\",\n \"minDelayMs\": \"0\",\n \"maxDelayMs\": \"0\",\n \"clientRefId\": \"42\",\n \"split\": 1,\n \"gasless\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://payments.magicblock.app/v1/spl/transfer")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from\": \"3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE\",\n \"to\": \"Bt9oNR5cCtnfuMmXgWELd6q5i974PdEMQDUE55nBC57L\",\n \"mint\": \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n \"amount\": 1000000,\n \"visibility\": \"private\",\n \"fromBalance\": \"base\",\n \"toBalance\": \"base\",\n \"exactOut\": false,\n \"initIfMissing\": true,\n \"initAtasIfMissing\": true,\n \"initVaultIfMissing\": false,\n \"memo\": \"Order #1042\",\n \"minDelayMs\": \"0\",\n \"maxDelayMs\": \"0\",\n \"clientRefId\": \"42\",\n \"split\": 1,\n \"gasless\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://payments.magicblock.app/v1/spl/transfer")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from\": \"3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE\",\n \"to\": \"Bt9oNR5cCtnfuMmXgWELd6q5i974PdEMQDUE55nBC57L\",\n \"mint\": \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n \"amount\": 1000000,\n \"visibility\": \"private\",\n \"fromBalance\": \"base\",\n \"toBalance\": \"base\",\n \"exactOut\": false,\n \"initIfMissing\": true,\n \"initAtasIfMissing\": true,\n \"initVaultIfMissing\": false,\n \"memo\": \"Order #1042\",\n \"minDelayMs\": \"0\",\n \"maxDelayMs\": \"0\",\n \"clientRefId\": \"42\",\n \"split\": 1,\n \"gasless\": true\n}"
response = http.request(request)
puts response.read_body{
"kind": "transfer",
"version": "legacy",
"transactionBase64": "<string>",
"sendTo": "base",
"recentBlockhash": "<string>",
"lastValidBlockHeight": 123,
"instructionCount": 1,
"requiredSigners": [
"<string>"
],
"from": "base",
"validator": "<string>",
"fees": {
"lamports": "<string>",
"tokens": "<string>"
}
}Private Payments API
转移 SPL Tokens
POST
/
v1
/
spl
/
transfer
Transfer SPL Tokens
curl --request POST \
--url https://payments.magicblock.app/v1/spl/transfer \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"from": "3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE",
"to": "Bt9oNR5cCtnfuMmXgWELd6q5i974PdEMQDUE55nBC57L",
"mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"amount": 1000000,
"visibility": "private",
"fromBalance": "base",
"toBalance": "base",
"exactOut": false,
"initIfMissing": true,
"initAtasIfMissing": true,
"initVaultIfMissing": false,
"memo": "Order #1042",
"minDelayMs": "0",
"maxDelayMs": "0",
"clientRefId": "42",
"split": 1,
"gasless": true
}
'import requests
url = "https://payments.magicblock.app/v1/spl/transfer"
payload = {
"from": "3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE",
"to": "Bt9oNR5cCtnfuMmXgWELd6q5i974PdEMQDUE55nBC57L",
"mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"amount": 1000000,
"visibility": "private",
"fromBalance": "base",
"toBalance": "base",
"exactOut": False,
"initIfMissing": True,
"initAtasIfMissing": True,
"initVaultIfMissing": False,
"memo": "Order #1042",
"minDelayMs": "0",
"maxDelayMs": "0",
"clientRefId": "42",
"split": 1,
"gasless": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from: '3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE',
to: 'Bt9oNR5cCtnfuMmXgWELd6q5i974PdEMQDUE55nBC57L',
mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
amount: 1000000,
visibility: 'private',
fromBalance: 'base',
toBalance: 'base',
exactOut: false,
initIfMissing: true,
initAtasIfMissing: true,
initVaultIfMissing: false,
memo: 'Order #1042',
minDelayMs: '0',
maxDelayMs: '0',
clientRefId: '42',
split: 1,
gasless: true
})
};
fetch('https://payments.magicblock.app/v1/spl/transfer', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://payments.magicblock.app/v1/spl/transfer",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'from' => '3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE',
'to' => 'Bt9oNR5cCtnfuMmXgWELd6q5i974PdEMQDUE55nBC57L',
'mint' => 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
'amount' => 1000000,
'visibility' => 'private',
'fromBalance' => 'base',
'toBalance' => 'base',
'exactOut' => false,
'initIfMissing' => true,
'initAtasIfMissing' => true,
'initVaultIfMissing' => false,
'memo' => 'Order #1042',
'minDelayMs' => '0',
'maxDelayMs' => '0',
'clientRefId' => '42',
'split' => 1,
'gasless' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://payments.magicblock.app/v1/spl/transfer"
payload := strings.NewReader("{\n \"from\": \"3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE\",\n \"to\": \"Bt9oNR5cCtnfuMmXgWELd6q5i974PdEMQDUE55nBC57L\",\n \"mint\": \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n \"amount\": 1000000,\n \"visibility\": \"private\",\n \"fromBalance\": \"base\",\n \"toBalance\": \"base\",\n \"exactOut\": false,\n \"initIfMissing\": true,\n \"initAtasIfMissing\": true,\n \"initVaultIfMissing\": false,\n \"memo\": \"Order #1042\",\n \"minDelayMs\": \"0\",\n \"maxDelayMs\": \"0\",\n \"clientRefId\": \"42\",\n \"split\": 1,\n \"gasless\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://payments.magicblock.app/v1/spl/transfer")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from\": \"3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE\",\n \"to\": \"Bt9oNR5cCtnfuMmXgWELd6q5i974PdEMQDUE55nBC57L\",\n \"mint\": \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n \"amount\": 1000000,\n \"visibility\": \"private\",\n \"fromBalance\": \"base\",\n \"toBalance\": \"base\",\n \"exactOut\": false,\n \"initIfMissing\": true,\n \"initAtasIfMissing\": true,\n \"initVaultIfMissing\": false,\n \"memo\": \"Order #1042\",\n \"minDelayMs\": \"0\",\n \"maxDelayMs\": \"0\",\n \"clientRefId\": \"42\",\n \"split\": 1,\n \"gasless\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://payments.magicblock.app/v1/spl/transfer")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from\": \"3rXKwQ1kpjBd5tdcco32qsvqUh1BnZjcYnS5kYrP7AYE\",\n \"to\": \"Bt9oNR5cCtnfuMmXgWELd6q5i974PdEMQDUE55nBC57L\",\n \"mint\": \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n \"amount\": 1000000,\n \"visibility\": \"private\",\n \"fromBalance\": \"base\",\n \"toBalance\": \"base\",\n \"exactOut\": false,\n \"initIfMissing\": true,\n \"initAtasIfMissing\": true,\n \"initVaultIfMissing\": false,\n \"memo\": \"Order #1042\",\n \"minDelayMs\": \"0\",\n \"maxDelayMs\": \"0\",\n \"clientRefId\": \"42\",\n \"split\": 1,\n \"gasless\": true\n}"
response = http.request(request)
puts response.read_body{
"kind": "transfer",
"version": "legacy",
"transactionBase64": "<string>",
"sendTo": "base",
"recentBlockhash": "<string>",
"lastValidBlockHeight": 123,
"instructionCount": 1,
"requiredSigners": [
"<string>"
],
"from": "base",
"validator": "<string>",
"fees": {
"lamports": "<string>",
"tokens": "<string>"
}
}请求体
application/json
响应
Unsigned serialized transaction

