Gateway between Front App and the detherContracts.
DetherJS is Javascript SDK to easily interact with DetherContracts
It provides wrappers for all the public methods of the contract and formats values in and out.
Use NPM to get the package
npm install --save detherjs
or
yarn add detherjs
In detherJS you can instanciate 2 object:
import DetherJS from "dether.js";
const detherjs = new DetherJS({
network: "mainnet" // can be kovan or ropsten
});
network
: NetworkrpcURL
: Provider URLetherscanKey
: Etherscan keyNew instance of DetherJS
const addr = '0xab5801a7d398351b8be11c439e05c5b3259aec9b';
try {
const teller = await detherjs.getTeller(addr)
} catch () {
console.log(e);
}
addr
: Ethereum address{
lat: 1, // Latitude
lng: 2, // Longitude
countryId: 'FR', // Country ID
postalCode: 75019,
escrowBalance: 0.01, // Escrow balance
rates: 20, // Fees
volumeTrade: 0, // Volume of Trade
nbTrade: 0, // Number of trade
currencyId: 1, // Currency id (1 === 'USD')
avatarId: 1, // Avatar ID
messengerAddr1: 'bobychou', // Telegram username
ethAddress: '0x085b30734fD4f48369D53225b410d7D04b2d9011', // Ethereum address
}
try {
const allTellers = await detherjs.getAllTellers();
console.log(allTellers);
} catch (e) {
console.log(e);
}
getAllTellers
can receive an array of addresses
addrs
: Array of ethereum addressesArray of tellers
You can specify a zone to get all the tellers presents in this zone
const opts = {
countryId: 'CZ', // CZ for Czech republic
postalCode: '170 00'
};
try {
const tellersInZone = await detherjs.getZoneTeller(opts);
} catch (e) {
console.log(e);
}
getZoneTeller
can receive an array of zones ID
opts
: params objopts.countryId
: ISO2 country codeopts.postalCode
: country postal CodeArray of tellers
const addr = "ETH_ADDRESS";
try {
const balance = await detherjs.getTellerBalance(addr);
} catch (e) {
console.log(e);
}
addr
: Ethereum addressReceive escrow balance of teller
You need to create a user:
const privateKey = 'PRIV_KEY';
const userPassword = '1234';
const wallet = new DetherJS.Ethers.Wallet(privateKey);
const encryptedWallet = await wallet.encrypt(userPassword);
const User = await dether.getUser(encryptedWallet);
User need to be certify first
const password = "123456789";
const opts = {
lat: 1.12,
lng: 2.21,
countryId: "CZ",
postalCode: "170 00",
rates: 20.2,
avatar: 1,
currencyId: 2,
messenger: "telegram",
amount: 0.1
};
try {
const hash = await User.addTeller(opts, password);
} catch (e) {
console.log(e);
}
opts
: params objectopts.lat
: Latitudeopts.lng
: Longitudeopts.countryId
: Country IDopts.postalCode
: Postal codeopts.rates
: rates a selleropts.buyRates
: rates as a buyeropts.rates
: true if teller is buyeropts.avatar
: Avatar IDopts.currencyId
: Currency id (1 === ‘USD’)opts.messenger
: Telegram usernameopts.amount
: Escrow balancepassword
: Password to decrypt the walletReturn receipt of transaction
As a seller, add Eth in your sell point
const password = "123456789";
const opts = {
amount: 1, // 1 ETHER
gasPrice: 20000000000 // 20 GWEI
};
try {
const hash = await User.addEth(opts, password);
} catch (e) {
console.log(e);
}
opts
: params objectopts.amount
: amount to addopts.gasPrice
: gasPrice for the tsx in WEIpassword
: Password to decrypt the walletReturn receipt of transaction
const password = 'Pass';
const opts = {
amount: 0.1,
receiver: 'ETH_ADDRESS',
};
try {
const sendCoinTransaction = await User.sendToBuyer(opts, password);
} catch (e) {
console.log(e);
}
password
: Password to decrypt the walletopts.amount
: Amount to sendopts.receiver
: Receiver’s ethereum addressReturn receipt of transaction
const password = "123456789";
try {
const hash = await User.deleteSellPoint(password);
} catch (e) {
console.log(e);
}
password
: Password to decrypt the walletReturn receipt of transaction
the address who certify need to be delegate. For this version only dether is delegate.
const password = "123456789";
const opts = {
user: "0x0", // eth address
nonce: 1, //
gasPrice: 20000000000 // 20 GWEI
};
try {
const hash = await User.certifyNewUser(opts, password);
} catch (e) {
console.log(e);
}
opts
: params objectopts.user
: ethereum addressopts.nonce
: tsx nonceopts.gasPrice
: tsx gasPricepassword
: password to decrypt the walletReturn receipt of transaction
For Dapp willing to certify user using the dether sms verification, you need to do an API call
TO DO
## TO DO
Add certify new user API