Gestione dei wallet
Per iniziare con i wallet su Chaingateway
Sezione intitolata “Per iniziare con i wallet su Chaingateway”Introduzione
Sezione intitolata “Introduzione”Chaingateway offre due metodi per generare wallet: wallet protetti da password e wallet non protetti. Di seguito descriviamo entrambi gli approcci, le loro implicazioni di sicurezza ed esempi di utilizzo.
1. Wallet protetti da password (consigliato)
Sezione intitolata “1. Wallet protetti da password (consigliato)”Se fornisci un parametro password nel corpo della tua richiesta a /api/v2/{blockchain}/addresses, la private key del wallet generato verrà archiviata in modo sicuro in formato crittografato.
Meccanismo di sicurezza
Sezione intitolata “Meccanismo di sicurezza”- La private key viene crittografata usando la tua password e ulteriori meccanismi di crittografia interni.
- Quando invii transazioni, fornisci la
passwordinvece della private key. - Questo metodo aumenta la sicurezza garantendo che le private key non siano mai esposte nelle richieste API.
Gestione della password
Sezione intitolata “Gestione della password”- Aggiornamento della password: Usa
UPDATE /api/v2/{blockchain}/addresses/{address}con i parametriold_passwordenew_password. - Esportazione della private key: Usa
POST /api/v2/{blockchain}/addresses/export/{address}per recuperare la tua private key (richiede la password).
::: danger Conserva la tua password in modo sicuro Non memorizziamo mai private key o password all’interno della nostra applicazione — né nel nostro database, né nei nostri meccanismi di logging o gestione delle eccezioni. Se perdi la tua password, non possiamo ripristinare la private key del tuo wallet. :::
Esempio di richiesta
Sezione intitolata “Esempio di richiesta”curl --request POST \ --url https://app.chaingateway.io/api/v2/ethereum/addresses \ --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \ --header 'Content-Type: application/json' \ --data '{ "password": "architecto"}'<?php$ch = curl_init();curl_setopt($ch, CURLOPT_URL, 'https://app.chaingateway.io/api/v2/ethereum/addresses');curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(["password" => "architecto"]));curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer YOUR_SECRET_TOKEN', 'Content-Type': 'application/json']);$response = curl_exec($ch);curl_close($ch);echo $response;fetch('https://app.chaingateway.io/api/v2/ethereum/addresses', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_SECRET_TOKEN', 'Content-Type': 'application/json' }, body: JSON.stringify({ password: 'architecto' })}).then(response => response.json()).then(data => console.log(data));import requestsheaders = { 'Authorization': 'Bearer YOUR_SECRET_TOKEN', 'Content-Type': 'application/json'}data = {"password": "architecto"}response = requests.post('https://app.chaingateway.io/api/v2/ethereum/addresses', headers=headers, json=data)print(response.json())Esempio di transazioni
Sezione intitolata “Esempio di transazioni”curl --request POST \ --url https://app.chaingateway.io/api/v2/ethereum/transactions \ --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \ --header 'Content-Type: application/json' \ --data '{ "from": "0xSenderAddress", "to": "0xRecipientAddress", "amount": "100", "password": "password"}'2. Wallet non protetti (da usare con cautela)
Sezione intitolata “2. Wallet non protetti (da usare con cautela)”Se non fornisci una password nella tua richiesta di creazione dell’indirizzo, la private key verrà restituita direttamente nella risposta. Questo significa che la private key deve essere archiviata e gestita in modo sicuro dal tuo lato.
::: danger Da usare solo per wallet non permanenti Poiché la private key è inclusa nella risposta, è tua responsabilità archiviarla e proteggerla in modo sicuro. Ti consigliamo vivamente di utilizzare invece wallet protetti da password. Se qualcuno ottiene l’accesso alla tua private key, può controllare tutti i fondi nel wallet. :::
Rischi per la sicurezza
Sezione intitolata “Rischi per la sicurezza”- La private key è esposta nella risposta dell’API, rendendola vulnerabile se intercettata.
- Se un aggressore ottiene l’accesso alla private key, può controllare completamente il wallet.
- Questo metodo dovrebbe essere usato solo per wallet temporanei o indirizzi monouso.
Esempio di richiesta
Sezione intitolata “Esempio di richiesta”curl --request POST \ --url https://app.chaingateway.io/api/v2/tron/addresses \ --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \ --header 'Content-Type: application/json'<?php$ch = curl_init();curl_setopt($ch, CURLOPT_URL, 'https://app.chaingateway.io/api/v2/tron/addresses');curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(["activated" => true]));curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer YOUR_SECRET_TOKEN', 'Content-Type': 'application/json']);$response = curl_exec($ch);curl_close($ch);echo $response;fetch('https://app.chaingateway.io/api/v2/tron/addresses', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_SECRET_TOKEN', 'Content-Type': 'application/json' }, body: JSON.stringify({ activated: true })}).then(response => response.json()).then(data => console.log(data));import requestsheaders = { 'Authorization': 'Bearer YOUR_SECRET_TOKEN', 'Content-Type': 'application/json'}data = {"activated": True}response = requests.post('https://app.chaingateway.io/api/v2/tron/addresses', headers=headers, json=data)print(response.json())Esempio di transazioni
Sezione intitolata “Esempio di transazioni”curl --request POST \ --url https://app.chaingateway.io/api/v2/ethereum/transactions \ --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \ --header 'Content-Type: application/json' \ --data '{ "from": "0xSenderAddress", "to": "0xRecipientAddress", "amount": "100", "password": "password"}'