2. Withdraw Funds

Description

Make a withdrawal from an account.

TBD: Narratives

User Interface

Function Description

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);
    }
});

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

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

Last updated