Frontend terang & responsif buat FastAPI wallet API kamu (EVM & Solana).
Generate wallet dari seed phrase via endpoint /create-wallet.
Import wallet dari seed phrase atau private key via endpoint /import-wallet.
Tes cepat endpoint /transfer-asset dengan input manual.
nohup../check-backend.sh | View logs: tail -f logs/backend.log
index.php + api.php./var/www/wallet-api atau C:\Users\Gamer\EVM.chains/ dan file main.py ada di root project.localhost:3000 kalau di VPS.php -v berfungsi).http://localhost:8000/index.php untuk UI atau panggil http://localhost:8000/api.php untuk proxy API.Endpoint: POST /create-wallet
Generate wallet dari seed phrase.
curl -X POST http://127.0.0.1:3001/create-wallet \
-H "Content-Type: application/json"
const response = await fetch('http://127.0.0.1:3001/create-wallet', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
// {
// "seed_phrase": "word1 word2 ... word12",
// "evm": {
// "address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
// "private_key": "0x1234567890abcdef..."
// },
// "solana": {
// "address": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
// "private_key": "base58encoded64bytes..."
// }
// }
$ch = curl_init('http://127.0.0.1:3001/create-wallet');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
print_r($data);
curl_close($ch);
import requests
response = requests.post(
'http://127.0.0.1:3001/create-wallet',
headers={'Content-Type': 'application/json'}
)
data = response.json()
print(data)
# {
# "seed_phrase": "word1 word2 ... word12",
# "evm": {
# "address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
# "private_key": "0x1234567890abcdef..."
# },
# "solana": {
# "address": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
# "private_key": "base58encoded64bytes..."
# }
# }
Response (200 OK):
{
"seed_phrase": "word1 word2 word3 ... word12",
"evm": {
"address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"private_key": "0x1234567890abcdef..."
},
"solana": {
"address": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
"private_key": "base58encoded64bytes..."
}
"tron": {
"address": "TXYZabcdefghijklmnopqrstuvwxyz123456",
"private_key": "93c6fc465721b17285b7749a499f098b0739ec81fce47344e40be0f643805d37"
}
}
Endpoint: POST /import-wallet
Import wallet dari seed phrase atau private key.
curl -X POST http://127.0.0.1:3001/import-wallet \
-H "Content-Type: application/json" \
-d '{
"input": "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
}'
const response = await fetch('http://127.0.0.1:3001/import-wallet', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
input: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
})
});
const data = await response.json();
console.log(data);
$ch = curl_init('http://127.0.0.1:3001/import-wallet');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'input' => 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
]));
$response = curl_exec($ch);
$data = json_decode($response, true);
print_r($data);
curl_close($ch);
import requests
import json
response = requests.post(
'http://127.0.0.1:3001/import-wallet',
headers={'Content-Type': 'application/json'},
json={
'input': 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
}
)
data = response.json()
print(data)
Response (200 OK) - dari seed phrase:
{
"evm_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"evm_private_key": "0x1234567890abcdef...",
"solana_address": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
"solana_private_key": "base58encoded64bytes...",
"tron_address": "TXYZabcdefghijklmnopqrstuvwxyz123456",
"tron_private_key": "93c6fc465721b17285b7749a499f098b0739ec81fce47344e40be0f643805d37",
"type": "phrase",
"message": "Successfully imported wallet from phrase"
}
Endpoint: POST /transfer-asset
Transfer native token (ETH, MATIC, SOL, dll) pada berbagai chain.
curl -X POST http://127.0.0.1:3001/transfer-asset \
-H "Content-Type: application/json" \
-d '{
"chain": "ethereum",
"to_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"private_key": "0xYOUR_PRIVATE_KEY",
"amount": "0.01"
}'
const response = await fetch('http://127.0.0.1:3001/transfer-asset', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
chain: 'ethereum',
to_address: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
private_key: '0xYOUR_PRIVATE_KEY',
amount: '0.01'
})
});
const data = await response.json();
console.log(data);
$ch = curl_init('http://127.0.0.1:3001/transfer-asset');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'chain' => 'ethereum',
'to_address' => '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
'private_key' => '0xYOUR_PRIVATE_KEY',
'amount' => '0.01'
]));
$response = curl_exec($ch);
$data = json_decode($response, true);
print_r($data);
curl_close($ch);
import requests
response = requests.post(
'http://127.0.0.1:3001/transfer-asset',
headers={'Content-Type': 'application/json'},
json={
'chain': 'ethereum',
'to_address': '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
'private_key': '0xYOUR_PRIVATE_KEY',
'amount': '0.01'
}
)
data = response.json()
print(data)
Response (200 OK):
{
"chain": "ethereum",
"from": "0x...",
"to": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"amount": "0.01",
"txid": "0xabc123...",
"explorer_url": "https://etherscan.io/tx/0xabc123..."
}
Endpoint: POST /transfer-token
Transfer token ERC20 (EVM) atau SPL (Solana) pada berbagai chain.
curl -X POST http://127.0.0.1:3001/transfer-token \
-H "Content-Type: application/json" \
-d '{
"chain": "ethereum",
"to_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"private_key": "0xYOUR_PRIVATE_KEY",
"amount": "100",
"contract_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
}'
const response = await fetch('http://127.0.0.1:3001/transfer-token', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
chain: 'ethereum',
to_address: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
private_key: '0xYOUR_PRIVATE_KEY',
amount: '100',
contract_address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
})
});
const data = await response.json();
console.log(data);
$ch = curl_init('http://127.0.0.1:3001/transfer-token');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'chain' => 'ethereum',
'to_address' => '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
'private_key' => '0xYOUR_PRIVATE_KEY',
'amount' => '100',
'contract_address' => '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
]));
$response = curl_exec($ch);
$data = json_decode($response, true);
print_r($data);
curl_close($ch);
import requests
response = requests.post(
'http://127.0.0.1:3001/transfer-token',
headers={'Content-Type': 'application/json'},
json={
'chain': 'ethereum',
'to_address': '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
'private_key': '0xYOUR_PRIVATE_KEY',
'amount': '100',
'contract_address': '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
}
)
data = response.json()
print(data)
Response (200 OK): Sama seperti transfer native, plus field "contract_address"
Endpoint: POST /estimate-gas
Estimasi gas fee untuk transfer native token atau token ERC20/SPL.
curl -X POST http://127.0.0.1:3001/estimate-gas \
-H "Content-Type: application/json" \
-d '{"chain": "ethereum", "amount": "0.1"}'
const response = await fetch('http://127.0.0.1:3001/estimate-gas', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
chain: 'ethereum',
amount: '0.1'
})
});
const data = await response.json();
console.log(data);
$ch = curl_init('http://127.0.0.1:3001/estimate-gas');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'chain' => 'ethereum',
'amount' => '0.1'
]));
$response = curl_exec($ch);
$data = json_decode($response, true);
print_r($data);
curl_close($ch);
import requests
response = requests.post(
'http://127.0.0.1:3001/estimate-gas',
headers={'Content-Type': 'application/json'},
json={
'chain': 'ethereum',
'amount': '0.1'
}
)
data = response.json()
print(data)
Response (200 OK):
{
"chain": "ethereum",
"type": "native_transfer",
"estimated_gas": 21000,
"gas_price_wei": "20000000000",
"gas_price_gwei": "20.000000000",
"total_fee_wei": "420000000000000",
"total_fee": "0.00042000000000000000 ETH"
}
Endpoint: GET /supported-chains
Mendapatkan daftar chain yang didukung oleh API.
curl http://127.0.0.1:3001/supported-chains
const response = await fetch('http://127.0.0.1:3001/supported-chains');
const data = await response.json();
console.log(data);
// {
// "chains": [
// "ethereum", "arbitrum", "avalanche", "base", "bnb",
// "celo", "linea", "optimism", "polygon", "zksync", "solana", "tron"
// ]
// }
$ch = curl_init('http://127.0.0.1:3001/supported-chains');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);
print_r($data);
curl_close($ch);
import requests
response = requests.get('http://127.0.0.1:3001/supported-chains')
data = response.json()
print(data)
Response (200 OK):
{
"chains": [
{
"name": "ethereum",
"logo": "data:image/svg+xml;base64,..."
},
{
"name": "arbitrum",
"logo": "data:image/svg+xml;base64,..."
},
...
]
}
Note: Setiap chain object berisi name dan logo (base64 encoded).
Untuk menggunakan logo custom, buat folder logos/ dan tambahkan file {chain_name}.svg atau {chain_name}.png.
api.php)Semua endpoint bisa diakses via api.php dengan parameter ?action=...
?action=create_evm_wallet → POST /create-wallet?action=import_wallet → POST /import-wallet?action=transfer_asset → POST /transfer-asset?action=transfer_token → POST /transfer-tokenmain.py (+ modul chains/).api.php hanya nerusin request ke FastAPI (proxy).index.php adalah UI simple yang pakai fetch() ke api.php supaya terasa kayak app tanpa reload.