Dexilon API Documentation
  • 👋Getting Started
  • General Info
    • ⚙️General API information
      • Base URLs
      • HTTP Return Codes
      • Enum Definition
    • 💻Clients
      • Dexilon Chain Client
    • 🚦Limits
      • REST API Rate limits
      • WS Stream Rate Limits
    • 🔐Security
      • Registration Flow
      • Authentication Flow
      • Sending Dexilon Transactions
      • Private API Calls
        • Access Token
        • Refresh Access Token
      • Timing security
    • ⚠️Error Codes
      • REST API Error Codes
      • WS Stream Error Codes
    • 🔍Audits
      • Bridge Audit
      • Smart-Contract Audit
  • Restful API
    • 📊Market Data Endpoints
      • Test Connectivity
      • Check Server Time
      • Exchange Information
      • Order Book
      • Recent Trades List
      • Kline/Candlestick Data
      • Symbol Data
      • Funding Rate History
      • Open Interest
      • Taker Buy/Sell Volume
      • Index Price History
      • Fee Tiers Structure
      • Fee Tiers Discount
      • Symbol Rules
      • Leverage Rules
    • ⚒️Account and Trades Endpoints
      • 🔒Account Information
      • 🔒Get User Address
      • 🔒Positions Information
      • 🔒Assets Information
      • 🔒Change Initial Leverage
      • 🔒Change Margin Type
      • 🔒Modify Isolated Position Margin
      • 🔒Create Withdrawal
      • 🔒Create market order
      • 🔒Create limit order
      • 🔒Cancel Order
      • 🔒Cancel All Orders
      • 🔒Query Order
      • 🔒Get Open Orders
      • 🔒Get Order History
      • 🔒Get Trade History
      • 🔒Get Transaction History
    • 🏆Rewards Endpoints
      • Current Reward Round
      • Reward Distribution
      • Rewards Settings
      • Current Tournament
      • Tournament Members
      • 🔒User's Reward Distributions
      • 🔒User's Reward Round Profit
      • 🔒User's Tournament Rating
    • 💸Liquidation Auctions Endpoints
      • Open Lots
      • Lot History
      • 🔒Place Bid
  • WebSocket Streams
    • 📈Market Data WS Streams
      • Working with Public Streams
      • Mark Price Stream
      • Mark Price Stream For All Markets
      • Kline/Candlestick Stream
      • Ticker Stream
      • Ticker Stream For All Markets
      • Partial Book Depth Stream
      • Book Ticker Stream
      • Trade Stream
      • Aggregate Trade Stream
      • Liquidation Trade Stream
      • Liquidation Auction Stream
    • 👥User Data WS Stream
      • 🔒Working with Private Streams
      • 🔒Order Update Stream
      • 🔒Account Update Stream
      • 🔒L2 Account Update Stream
Powered by GitBook
On this page
  • Create permissions for a temporary account - aka Authorization
  • Step 1: Create a temporary Wallet
  • Step 2: Create a web3 Wallet instance
  • Step 3: Create an ECDSA signature with your Ethereum Wallet
  • Step 4: Send a Grant Permission transaction to Dexilon
  • Next steps
  1. General Info
  2. Security

Authentication Flow

Create a temporary (or "session") wallet with your Ethereum Wallet to get access to your funds on Dexilon Chain

Create permissions for a temporary account - aka Authorization

Step 1: Create a temporary Wallet

const granteeWallet = await getRandomCosmosAddress();

await api.faucet(granteeWallet.address);

const granteeClient = new DexilonClient(granteeWallet.wallet, api, config);
await granteeClient.init();

Step 2: Create a web3 Wallet instance

To create an ECDSA signature with your Ethereum Wallet, you need to create an instance of it in the code:

const ethNetwork = 80001; // Polygon mumbai is used as L1 for Dexilon Testnet 
const etherWallet = ethWalletFromMnemonic("<your ether mnemonic here>");
const ethAddress = etherWallet.address;

Step 3: Create an ECDSA signature with your Ethereum Wallet

const dataStructure = ['string'];
const timestamp = Math.floor((new Date().getTime() + 3 * 60 * 1000) / 1000.0);
const signedMessage = `${timestamp}#${granteeWallet.address}`;
const granterSinature = await getSignature(etherWallet, [signedMessage], dataStructure);

Step 4: Send a Grant Permission transaction to Dexilon

const expirationTime = 15 * 60;
const txRepsonse = await granteeClient.grantPermissions(
        ethAddress,
        granterSinature,
        signedMessage,
        expirationTime,
        ethNetwork,
);
curl --location 'https://proxy.staging.dexilon.io/cosmos/tx/v1beta1/txs' \
--header 'Content-Type: application/json' \
--data '{
    "tx_bytes": "Cu0CCuoCCkIvZGV4aWxvbl9leGNoYW5nZS5kZXhpbG9uTDIucmVnaXN0cmF0aW9uLk1zZ0dyYW50UGVybWlzc2lvblJlcXVlc3QSowIKLWNvc21vczFweXJqNzRtNmp0ODNuZjJ6a3FsODB0dm5tazh5MmhudW0wZ3ZoehIqMHhCNjJGZjZhQ2Y5QkE0ODQ5NkExOTAyMEM4MDdmRTY4NmI1M0MyNkI2GoQBMHg3ZjA5NzRiZjg5ZDkxODNiYzE2Y2I5NWUyMDc5NWZjM2Y0Mjk1NzA4ZmNjODJlMGI5MDMwZmI5ZTk0NDk2NzUwNjdjZjVmY2Q4MDI5NDFmZjJjYTg3YjE5ZDJjNTE5ZjNkMDJlYTQ1ZGIwYjE5MDdiYTQ1MGVkZDUyM2ZlMGE5YjFiIjgxNjgwMDAxMjg4I2Nvc21vczFweXJqNzRtNmp0ODNuZjJ6a3FsODB0dm5tazh5MmhudW0wZ3ZoeiiEBzCloy0SYQpOCkYKHy9jb3Ntb3MuY3J5cHRvLnNlY3AyNTZrMS5QdWJLZXkSIwohAjF277bEhPveUWPtGkmz4A+76Kbca3EggzRZ88hGgmgTEgQKAggBEg8KCQoEZHhsbhIBMBDAmgwaQP0EOzTvoRRH2q9+6WtkQCqCUdotLJ0jUDbtgTJT//q1DuuBUjfcHxjDWONsg2USU0HHYy6d35PN8tgZMI46sQs=",
    "mode": "BROADCAST_MODE_BLOCK"
}'

Here you can see an example of grantee account creation and giving it the grants to control the fund of your primary account

After that you can use the granteeClient to control you funds on Dexilon using the methods of the SDK

Next steps

PreviousRegistration FlowNextSending Dexilon Transactions

Last updated 2 years ago

🔐
Sending Dexilon Transactions