Tronsave
🇬🇧 English
Search
K

Connect TronSave

Last version 1.1.34
You can download it:
With npm:
npm i @tronsave/sdk tronweb
With yarn:
yarn add @tronsave/sdk tronweb
First, you need to register the project and obtain an API key here.
Browser
Server
import { TronSave } from '@tronsave/sdk'
// TronSave can only be initialized when tronweb already exists
// Example code:
let tronSave = null;
const waitTronSave = () => {
return new Promise((res) => {
let attempts = 0,
maxAttempts = 20;
const checkTronWeb = () => {
if (window as any).tronWeb?.defaultAddress.base58) {
const options = {
apiKey: API_KEY,
network: "mainnet",
... //The options list is in the table below
}
res(new TronSave(window.tronWeb, options))
return;
}
attempts++;
if (attempts >= maxAttempts) {
res(null);
return;
}
setTimeout(checkTronWeb, 100);
};
checkTronWeb();
});
};
waitTronSave().then((res) => {
if (res) {
tronSave = res;
}
})
import { TronSave } from '@tronsave/sdk'
import TronWeb from 'tronweb'
const tronWeb = new TronWeb({
fullHost: 'https://api.trongrid.io',
...,
privateKey: 'your private key'
})
const options = {
apiKey: API_KEY,
network: "mainnet",
...
}
const tronSave = new TronSave(tronWeb, options)
This options configs validate and payment transactions

Config options TronSave

Params
Type
Description
Required
apiKey
string
API key dApp, If you don't have an valid API key, you cannot use the useRelay or forceUseRelay option.
false
networks
"mainnet" | "nile"
Node network mainnet or nile
true
domainName
string
Domain name
false
name
string
Name project
false
version
string
Version project
false
chainId
string
Chain id blockchain
false
verifyingContract
string
Address
false
validAfter
number
the highest block number the request can be forwarded in, or 0 if request validity is not time-limited
false
paymentMethodType
enum (default value is 1)
1 - Onchain WTRX 2 - Onchain Token (coming soon) 10 - User pay ( coming soon ) 11 - dApp pay for user 12 - dApp pay for the user but take a token (not supported yet )
false