bitofme
npm package to access bitofme smart contracts written in typescript
Install module
npm install bitofme
Register a test ENS Name (only for ganache/rinkeby regions. Wont work with mainnet)
const ensName = "atestname";await bitofme;
Setup ENSName for BitOfMe Rental
; const bitofme = "rinkeby";const ensName = "atestname";const referralWallet = "0xYourAddressToReceiveCommissions";const referralFeePPK = 20; //Parts per Kilo. For 1%, enter 10. For 1.5% enter 15. 2% is 20await bitofme; //creates the contractawait bitofme; //grants ENS name ownership
Register a subdomain
const ensName = "atestname";const subdomainName = "mysubdomain";const receipientWallet = "0xWalletToReceiveFunds";const adminWallet = "0xWalletThatCanInitiateRefunds";const encryptionKeys = bitofme;//Input fields separated by pipe. Optional fields enclosed by []. Dropdown questions end with the options in () separated by /const inputFields = "name|[address]|can we send you email?(yes/no)";const maxAllowedPayment = 1000;const fiatCurrency = "usd";const rentalContractAddress = await bitofme; //creates the contractconsole;
Initiate payment
const ensFullName = "mano.invoice.eth";const plainMessage = "Jack Frost|123 Main Street, TX|fake@email.com|y";const amount = 1000;const currencyCode = "usd";const gasPrices = await bitofme;const gasPriceGWeiForFastConfirmation = gasPricesfastGWei;const depositStatus = await bitofme;console;
Output:
true
Get encoded data for given input (to use with ledger nano s, trezor)
const ensFullName = "mano.invoice.eth";const plainMessage = "Jack Frost|123 Main Street, TX|fake@email.com|y";const amount = 1000;const currencyCode = "usd";const encodedData = await bitofme;console;
Output:
'0x53839ece0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000025800000000000000000000000000000000000000000000000000000000000000c23033333365656335383364303461353563653061626139646266623034303335653863366465346635303165636339623236633038666135303161356563313530376235336237316363653864646131623032346633663863373061303465643633306566666337383435363833313534626263623935626231323433343366376562633130643336613763366235323763366537666566386534316463653737396665616664653738366632626333303664323239663534613331646665303238000000000000000000000000000000000000000000000000000000000000'
Utility Functions
Generate encryption keypair
; const bitofme = "rinkeby";const keyPair = bitofme; console; //Warning: Never print private key to console!
Output:
{publicKey: '022f7148edd46fb3ef945ff4974b3c8213b713f2ec12ae2d1bb82aeb67dffdfc36', privateKey: '0x6782433bb0d4dee50218531af18a089d54
78180a04f71a3d559a042c706a3c8c'}
Encrypt/Decrypt messages
let plainMessage = "hello world"; let encryptedMessage = bitofme;let decryptedMessage = bitofme;console;
Output:
'encryptedMessage', '0333eec583d04a55ce0aba9dbfb04035e8c6de4f501ecc9b26c08fa501a5ec1507b53b71cce8dda1b024f3f8c70a04ed634c1e3366ce9301e648350b127f2798df61183693301f566dda6718229c3a0967f1438bb98696f1a1b7160d7499e60e55'
Get selected Account at the injected provider (if Metamask not installed or locked, this will be "")
let selectedAccount = await bitofme;console;
Output:
Selcted account', '0x627306090abab3a6e1400e9345bc60c78a8bef57'
Get conversion rate
const rate = await bitofme;console;
Output:
630.25
Get gas price estimates
const priceEstimate = await bitofme;console;
Output:
{safeLowGWei: 8, fastGWei: 14, fastestGWei: 20, averageGWei: 9, speed: 0.9967071778740859, safeLowWait: 9.3, averageWait: 5.8, fastWait: 0.5, fastestWait: 0.5}