Heads up! The StarkWare provider is currently only available for Ropsten testnet and not feature complete yet.
Getting started
Install authereum@next version:
npm install authereum@next
Instantiate the Authereum SDK and get StarkWare provider:
import Authereum from 'authereum'
const authereum = new Authereum('ropsten')
await authereum.login()
const starkProvider = authereum.getStarkProvider()
const starkKey = await starkProvider.getStarkKey()
console.log(starkKey)
These are the methods available under the Authereum StarkWare provider:
getStarkKey():Promise<string>
Returns the Stark key.
Arguments:
none
Returns:
Promise<string>: Returns a promise with stark key string.
Example:
getPublicKey():Promise<string>
Returns the Stark public key.
Arguments:
none
Returns:
Promise<string>: Returns a promise with stark public key string.
Example:
setContractAddress(contractAddress):Promise<void>
Sets the StarkEx contract address to use for the provider.
Arguments:
Returns:
Promise<void>
Example:
getContractAddress():Promise<string>
Returns the StarkEx contract address.
Arguments:
none
Returns:
Promise<string> : Returns a promise with contract address.
Example:
registerUser(ethKey, operatorSignature):Promise<string>
Submits a transaction to register the Stark key.
Arguments:
Ethereum EOA and account contract address
Operator signature required for registration
Returns:
Promise<string>: Returns a promise with transaction hash.
Example:
depositEth(vaultId, amount, quantum):Promise<string>
Submits a transaction to deposit ETH to vault.
Arguments:
ETH amount to deposit in wei (e.g. 1000000000000000)
Returns:
Promise<string>: Returns a promise with transaction hash.
Example:
depositErc20(vaultId, amount, quantum, token):Promise<string>
Submits a transaction to deposit ERC20 token to vault.
Arguments:
Token amount to deposit
(e.g. if decimals is 6, to deposit 0.42 it would be 420000)
Quantum value (e.g. 1000)
Returns:
Promise<>: Returns a promise with transaction hash.
Example:
depositErc721(vaultId, tokenId, token):Promise<string>
Submits a transaction to deposit ERC721 NFT to vault.
Arguments:
Returns:
Promise<string>: Returns a promise with transaction hash.
Example:
cancelDeposit(vaultId, assetType):Promise<string>
Submits transaction to cancel deposit.
Arguments:
Returns:
Promise<string>: Returns a promise with transaction hash.
Example:
reclaimDeposit(vaultId, assetType):Promise<string>
Submits transaction to reclaim deposit after cancelling deposit.
Arguments:
Returns:
Promise<string>: Returns a promise with transaction hash.
Example:
withdrawEth(quantum, recipient?):Promise<string>
Submits transaction to withdraw ETH from vault.
Arguments:
(Optional) Recipient address
Returns:
Promise<string>: Returns a promise with transaction hash.
Example:
withdrawErc20(quantum, token, recipient?):Promise<string>
Submits transaction to withdraw ERC20 token from vault.
Arguments:
Quantum value (e.g. 1000)
(Optional) Recipient address
Returns:
Promise<string>: Returns a promise with transaction hash.
Example:
withdrawErc721(tokenId, token, recipient?):Promise<string>
Submits transaction to withdraw ERC721 NFT from vault.
Arguments:
Quantum value (e.g. 1000)
(Optional) Recipient address
Returns:
Promise<string>: Returns a promise with transaction hash.
Example:
fullWithdrawalRequest(vaultId):Promise<string>
Submits transaction to do a request to withdraw all tokens from vault.
Arguments:
Returns:
Promise<string>: Returns a promise with transaction hash.
Example:
freezeRequest(vaultId):Promise<string>
Submits transaction to freeze vault.
Arguments:
Returns:
Promise<string>: Returns a promise with transaction hash.
Example:
escape(vaultId, assetType, quantizedAmount):Promise<string>
Submits transaction to request escape from frozen contract.
Arguments:
Quantized amount (e.g. amount / quantum)
Returns:
Promise<string>: Returns a promise with object containing transaction hash.
Example:
transfer({object}):Promise<string>
Transfer ETH, ERC20, or ERC721 to a stark account. Returns signature.
Arguments:
Object parameters:
Transfer recipient params.
(optional) Condition hash (encoded hash of transfer address and fact)
conditionalTransferAddress
(optional) Conditional transfer address (not needed if condition hash is set)
(optional) Condition transfer fact (not needed if condition hash is set)
Asset
Asset standard (e.g. ETH, ERC20, ERC721)
AssetData
Quantum value. Required if asset type is ETH or ERC20
Token address. Required if asset type is ERC20 or ERC721
Token ID. Required if asset type is ERC721
TransferParams
Returns:
Promise<string>: Returns a promise with transfer stark signature.
Example:
transferEth({object}):Promise<string>
Transfer ETH to a stark account. Returns signature.
Arguments:
Object parameters:
Conditional transfer hash
Returns:
Promise<string>: Returns a promise with transfer stark signature.
Example:
transferErc20({object}):Promise<string>
Transfer ERC20 token to a stark account. Returns signature.
Arguments:
Object parameters:
Conditional transfer hash
Returns:
Promise<string>: Returns a promise with transfer stark signature.
Example:
transferErc721({object}):Promise<string>
Transfer ERC721 token to a stark account. Returns signature.
Arguments:
Object parameters:
Conditional transfer hash
Returns:
Promise<string>: Returns a promise with transfer stark signature.
Example:
createOrder({object}):Promise<string>
Create a buy or sell limit order. Returns a signature
Arguments:
Object parameters:
OrderParams
Asset standard (e.g. ETH, ERC20, ERC721)
AssetData
Quantum value. Required if asset type is ETH or ERC20
Token address. Required if asset type is ERC20 or ERC721
Token ID. Required if asset type is ERC721
Returns:
Promise<string>:Returns a promise with transfer stark signature.
Example
deserializeSignature(signature)
Returns the r and s values of serialized signature.
Arguments:
Returns:
Promise<{r, s, recoveryParam?}>: Returns object
Example:
serializeSignature({r, s, recoveryParam?}):string
Returns the serialized signature.
Arguments:
(optional) Recovery parameter value
Returns:
Promise<string>: Returns serialized signature as hex string.
Example:
send(method, params):Promise<object>
Call StarkWare JSON RPC method with payload.
Arguments:
Method name (e.g. stark_transfer)
Object or array containing parameters
Returns:
Promise<{id, result}>: Returns promise with object containing response result.
Example:
getAssetType({assetStandard, assetContractAddress?, quantum?, amount?}):Promise<string>
Returns asset type hash.
TODO
starkSignMessage(msg):Promise<string>
Signs message with stark key.
TODO
signMessage(msg):Promise<string>
Signs message with ethereum key.
TODO
signPersonalMessage(msg):Promise<string>
Signs personal message with ethereum key.
TODO
signTransaction(tx):Promise<string>
Sign transaction.
TODO
sendTransaction(tx):Promise<string>
Send transaction.
TODO
estimateGas(tx):Promise<string>
Estimate gas.
TODO
Please refer to the StarkWare JSON RPC specification for example inputs.
You can test out StarkWare methods in the Authereum Ropsten Kitchen Sink.