Shield V2
HomeTrade
  • Overview
  • Shield perpetual options
    • Basics
    • Mechanism
  • Getting started
    • Guides
    • FAQs
      • About Shield
      • About Trading
      • About Pools
  • Developers
    • Trading API References
      • Overview
        • Smart Contracts Overview
      • Interfaces
        • 1. Deposit Funds
        • 2. Withdraw Funds
        • 3. Check Funds
        • 4. Deposit DAI into Public Pool
        • 5. Withdraw DAI from Public Pool
        • 6. Check Funds on Public Pool
        • 7. Deposit DAI to Private Pool
        • 8. Withdraw DAI from Private Pool
        • 9. Check Funds on Private Pool
        • 10. Check Details on a Certain Order
        • 11. Get Funding Fee Rate of an Option Transaction
      • "How-To" Instructions
        • How to monitor opening and closing orders?
      • Addendum
        • Full ABI on Shield Protocol V1
        • References
  • Additionals
    • Audits
    • Lightpaper
    • Pricing Method Paper
    • Privacy Policy
    • Terms of Use
Powered by GitBook
On this page
  • Description
  • User Interface
  • Function Description
  • ABI Description
  • Examples
  • Calling Examples
  • HTTP Request Example
  • Send a Withdrawal Transaction
  1. Developers
  2. Trading API References
  3. Interfaces

2. Withdraw Funds

Previous1. Deposit FundsNext3. Check Funds

Last updated 2 years ago

Description

Make a withdrawal from an account.

TBD: Narratives

User Interface

Function Description

Item

Description

Contract Address

Trading contract (referenced by Smart Contract Overview section)

Contract Name

SLDDAIContract.sol

Function

function withdraw(uint256 amount)

Function Selector

0x2e1a7d4d

Invocation Type

Ethereum Transaction

Passing Parameters

Amount of DAIs withdrawn; actual number multiplied by 1E18

Return Value

None

Event Emitted

event DDSWithdraw(address indexed sender, address indexed toAddr, uint256 motageAmount);

Event Signature

0x9319767067544c146c859088bc69f38236cad434eb28957e8574a56d4173f89f

Transaction Sample(BSC testnet)

ABI Description

[{
	"inputs": [{
		"internalType": "uint256",
		"name": "amount",
		"type": "uint256"
	}],
	"name": "withdraw",
	"outputs": [],
	"stateMutability": "nonpayable",
	"type": "function"
}]

Examples

Calling Examples

// This example is written by using Web3.js
// More details on Web3.js could be found here - https://web3js.readthedocs.io/

var Web3 = require('web3');
const BigNumber = require('bignumber.js');

// BSC Mainnet: https://bsc-dataseed.binance.org
// BSC Testnet: https://data-seed-prebsc-1-s1.binance.org:8545
const  web3 = new Web3("https://data-seed-prebsc-1-s1.binance.org:8545");

// Need trading contract address
const CONTRACT_ADDRESS = "";
const ABI = [{
	"inputs": [{
		"internalType": "uint256",
		"name": "amount",
		"type": "uint256"
	}],
	"name": "withdraw",
	"outputs": [],
	"stateMutability": "nonpayable",
	"type": "function"
}];

// Withdraw 1 DAI.
const DEPOSIT_AMOUNT = 1e18;

var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.withdraw(new BigNumber(DEPOSIT_AMOUNT).toString()).send({
    from: "CALLER_ADDRESS",
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});
# This example is written by using Web3.py
# More details on Web3.py could be found here - https://web3py.readthedocs.io/

HTTP Request Example

Send a Withdrawal Transaction

POST (BSC Mainnet) https://bsc-dataseed.binance.org/

Make a withdraw transaction to Shield Protocol V1 BSC network. More details on how to send a transaction via BSC RPC could be found here, https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction

Request Body

Name
Type
Description

jsonrpc

string

"2.0"

method

string

"eth_sendRawTransaction"

params

array

the signed transaction data coerced into string array

id

number

request sequence id, you could use timestamp as id

{
  "id":64,
  "jsonrpc": "2.0",
  "result": "0xb7d745f1d696281444530c798a408ad52cf221c6993bb16997f3b7f465e7c2d5"
}

https://testnet.bscscan.com/tx/0xb7d745f1d696281444530c798a408ad52cf221c6993bb16997f3b7f465e7c2d5#eventlog