Utilities

SimpleID provides some helper utilities to make your application interactions easier. They are laid out here.

Poll For Transaction

As long as you have an ethereum transaction hash, you can poll for the transaction status. This is helpful when you want to display transaction-based content but you're not sure if the transaction has been mined.

const status = await simple.pollForStatus(tx);

User Data

There will be pieces of user data that you'll need to fetch frequently as users interact with your application. SimpleID makes this easy by providing a helper function to fetch all or a portion of the data. Here's the function:

const userData = simple.getUserData();

That function returns an object like this:

{
"blockstack": {
"appUrl": "https://gaia.blockstack.org/hub/1G7CzE2KUDdf3CsEKUDVGcrTpprxqaU222/",
"public": "0214b600bca5c7673123234857ffeebcbea1534bb4c19769d1328717d023c99b2e",
"private": "6bbf2f44123cd6a9d38ed1bbd43cf051f1a3a23dcgf6b4f7ca3f3a712ba401d0",
"idAddress": "ID-18JMJxUFJv286zs1TqB5KGiRGcpdLh4kVe"
},
"wallet": {
"btcAddr": "151fk22VoYhNTLQz5SfyzS4vKawsV5ZDXD",
"ethAddr": "0x709eD1Aw2cc771C5D17a86422C121785eD7c2Cc0",
"stkAddr": "SPP01NYK2C9VP5TPD9Q9FP2SWR66NWEHR92GAX6J"
},
"email": "hello@simpleid.xyz",
"textile": "SVvvMDWerqGAmoJ8NVafnHD3CeRSIPuo462HA1QxQDbGwubY"
}

Blockstack Session

The helper function for returning a Blockstack user session is similar to the SimpleID getUserData helper, but in this case, it is specially designed to return the right format for Blockstack and it actually calls Blockstack library functions to build the session properly. You can call it like this:

const userSession = await simple.getBlockstackSession();

Web3 Provider

SimpleID takes care of the web3 provider necessary for interacting with Ethereum. However, if you ever want to return the provider, you can do so by calling this helper function.

const provider = await simple.getProvider();

Full Ethers.js Support

The final, but far from least, helper function within the SimpleID SDK is designed to extend the developer experience into more granular functionality. SimpleID will return the entire ethers.js library with this helper and developers who need to call additional ether.js specific functions can use this. Here's an example:

const simpleWeb3 = await simple.simpleWeb3();
const bigNum = simpleWeb3.utils.bigNumberify("20000000000");