DeBox Shares Protocol
DeBox Shares Protocal
What is DeBox Shares?
The DeBox Shares protocol is an empowerment tool provided by DeBox for developers, KOLs, and users. It is a set of APIs defined by DeBox that developers can use to create customized services, generating value for users and the platform.
On the DeBox platform, group owners, group members, and developers can all profit through the Shares protocol. This protocol incentivizes more users to participate in sharing, promoting, and using mini-programs by distributing a portion of DeBox platform's revenue to users.
Developers can create mini-programs based on the DeBox SDK and encourage DeBox users to use, promote, and share these mini-programs through revenue sharing. When users open a mini-program through a member's shared link, a portion of the user's spending in the program will be distributed to the sharer, DAO assets, and group owners, forming a virtuous cycle of revenue generation.
What participation methods does Shares support?
- Supports vBOX payments: Directly call the vBOX payment interface of DeBox-Shares;
- Supports on-chain Token payments: Call the DeBox-Shares contract and slightly adjust the DAPP's payment contract code;
- Supports multiple networks: Currently supports ETH, Arbitrum, Base, BSC, OP, Polygon network assets (continuously updating).
How to integrate Shares?
1. Integrate Shares with vBOX Payment
- The vBOX payment process includes two main steps: connecting the wallet and obtaining authorization, and calling the payment API to complete the payment. After the payment is completed, you can view the payment details. Here are the detailed steps and usage methods:
1.1 Connect Wallet and Request Authorization
-
DAPP can connect to the user's wallet and obtain the required user information through the DeBox Wallet SDK.
The DeBox Wallet SDK is a tool for DAPP to connect and interact with the DeBox wallet. When users open the webpage through the DeBox client, DeBox will automatically inject the
window.deboxWallet
object into the webpage (it can also be accessed through the aliaswindow.ethereum
). DAPP can use this object to detect whether the DeBox wallet is installed and call the corresponding API methods for operation. -
The following methods can be used for this process:
eth_requestAccounts: This method requests user wallet authorization to connect.
- Common wallet methods, extended by DeBox.
- Internally, this method calls
debox_getUserInfo
to request user information permissions. - This method will pop up a window asking the user to authorize the connection to the DAPP and obtain the wallet address.
Request:
await window.deboxWallet.request({
"method": "eth_requestAccounts",
"params": [],
});
Parameters:
- None
Response:
- Returns the user's wallet address upon success.
[
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
]
wallet_requestPermissions: This method requests user approval for DAPP access permissions.
- Methods that require prior user authorization include:
debox_getUserInfo
(to get user public information),debox_getVBoxBalance
(to get user's wallet vBOX balance).
-
Permission request information parameters are empty. By default, it will request user approval for the
debox_getUserInfo
method.Request:
await window.deboxWallet.request({
"method": "wallet_requestPermissions",
"params": [{
eth_accounts: {}
}],
});Parameters:
eth_accounts
: Its value is an empty object{}
, indicating a request for default permissions (i.e.,debox_getUserInfo
).
Response:
- Returns upon success:
[
{
"parentCapability": "eth_accounts",
"invoker": "https://connect-nu-one.vercel.app/",
"caveats": [
{
"type": "restrictReturnedAccounts",
"value": [
"0xa56b4f0c7622bd076c2ba48b17d1e8d3fbf5303e"
]
},
{
"type": "debox_getUserInfo",
"value": {
"uid":"jkdi123",
"address":"0xa56b4f0c7622bd076c2ba48b17d1e8d3fbf5303e",
"name":"Tom",
"avatar":"https://debox......png"
}
},
],
"date": 1728348403194
},
] -
Permission request information with parameters. At this time, the user will be asked to approve the permissions specified by the developer:
Request:
await window.deboxWallet.request({
"method": "wallet_requestPermissions",
"params": [{
eth_accounts: {
"debox_getUserInfo": {},
"debox_getVBoxBalance": {}
}
}],
});Parameters:
eth_accounts
property, with a value of an object specifying two permissions:"debox_getUserInfo"
: Request permission to get user information (e.g., avatar, nickname), with an empty object{}
as the value."debox_getVBoxBalance"
: Request permission to get the user's vBOX balance, with an empty object{}
as the value.
Response:
- Returns upon success:
[
{
"id": "QbOgSTaFmS3UK1qS6pese",
"parentCapability": "eth_accounts",
"invoker": "https://connect-nu-one.vercel.app/",
"caveats": [
{
"type": "restrictReturnedAccounts",
"value": [
"0xa56b4f0c7622bd076c2ba48b17d1e8d3fbf5303e"
]
},
{
"type": "debox_getUserInfo",
"value": {
"uid":"jkdi123",
"address":"0xa56b4f0c7622bd076c2ba48b17d1e8d3fbf5303e",
"name":"张三",
"avatar":"https://debox......png"
}
},
{
"type": "debox_getVBoxBalance",
"value": {
"usable_balance": 0.12
}
},
],
"date": 1728348403194
},
]
debox_getUserInfo: This method retrieves the user's public information, such as user ID, wallet address, nickname, and avatar.
- Prerequisite: The user has approved access to
debox_getUserInfo
viawallet_requestPermissions
, otherwise service is denied. - If the user has not authorized access to
debox_getUserInfo
, a confirmation box will pop up asking for authorization, or service will be denied.
Request:
await window.deboxWallet.request({
"method": "debox_getUserInfo",
"params": [],
});
Parameters:
- None
Response:
- Returns the user's basic information (ID, address, nickname, avatar) upon success if the user has authorized access.
{
"address":"0xa56b4f0c7622bd076c2ba48b17d1e8d3fbf5303e",
"name":"Tom",
"avatar":"https://debox......png",
"uid":"jkdi123"
}
debox_getVBoxBalance: This method retrieves the user's vBOX balance.
- Prerequisite: The user has approved access to
debox_getVBoxBalance
viawallet_requestPermissions
, otherwise service is denied.
Request:
await window.deboxWallet.request({
"method": "debox_getVBoxBalance",
"params": [],
});
- Returns the user's available vBOX balance (requires user authorization).
Parameters:
- None
Response:
- Returns the user's available vBOX balance upon success if the user has authorized access.
{
"usable_balance": 0.12
}
Error Codes
- When the user has not authorized the method call
{
"code": 4100,
"message": "The requested account and/or method has not been authorized by the user."
}
- When the user rejects the request
{
"code": 4001,
"message": "User rejected the request."
}
1.2 Call vBOX Payment API
- After user authorization, the Dapp frontend can call the debox_paymentVBox method for payment.
- The following methods can be used for this process:
debox_paymentVBox: This method performs vBOX payment, specifying the recipient address, payment amount, payment note, and shares amount.
- Prerequisite: Approved access to
debox_getUserInfo
viawallet_requestPermissions
, otherwise service is denied.
Request:
await window.deboxWallet.request({
"method": "debox_paymentVBox",
"params": [{
"receiver_address": "0x4c7d41C915a12BCe634d619144941a51FA83DfF5",
"amount": 100, // Amount of vBox to pay, minimum 0.01
"nonce": 12893019283,
"note": "Purchase item",
"donation_amount": 40
}],
});
- Users can input the recipient address, payment amount, note, and shares amount. The API will return the transaction result, such as order ID or payment status.
Parameters:
receiver_address
: Recipient's wallet address (payment fails if the address is invalid or non-existent).amount
: Amount of vBOX to pay, minimum 0.01.nonce
: Int64, optional, if empty, DeBox client generates using the current timestamp. This is an anti-replay code to prevent the same payment from being consumed multiple times.note
: Payment note, up to 100 characters.donation_amount
: Amount allocated to DeBox platform for shares, cannot exceedamount
.
Response:
order_id
: The order ID of this payment
{
"order_id": "0xd85554eb6e2ab48dd36209eb8db65d1fa540621c3679c7388f469ff314a194a8"
}
Error Codes
- When the user has not authorized the method call
{
"code": 4100,
"message": "The requested account and/or method has not been authorized by the user."
}
- When the user rejects the request
{
"code": 4001,
"message": "User rejected the request."
}
- The recipient address
receiver_address
must be a DeBox user's address. Otherwise, the payment fails with the message "Invalid parameter". - The recipient address
receiver_address
cannot be the same as the payer address. Otherwise, the payment fails with the message "System busy, please try again later".
1.3 Query Payment Result
- After calling debox_paymentVBox for payment, the Dapp can verify the receipt's authenticity:
- The following methods can be used for this process:
GET https://open.debox.pro/openapi/payment/receipt
: This endpoint is used to view detailed payment results.
https://open.debox.pro/openapi/payment/receipt
: This endpoint is used to view detailed payment results.Endpoint: https://open.debox.pro/openapi/payment/receipt
Request Method: GET
Request Example:
curl
https://open.debox.pro/openapi/payment/receipt?order_id=0x0aabbccxx
Parameters:
Header:
X-API-KEY
:String
- Developer key, obtainable from the open platform;
- Can be omitted for a small number of queries. Add this header to avoid rate limiting for a large number of requests.
Query:
order_id
:String
- The order ID of the payment
Response:
- On success:
{
"code": 1,
"data": {
"order_id": "0x0aabbccxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"receiver_id": "okqwerty",
"payer_id": "0cqwerte",
"amount": "0.02",
"fee": "0.01",
"invoker_note": "buy a cup of coffee"
},
"message": "success",
"success": true
}
- On failure:
{
"code": -4018,
"data": {
"amount": "0",
"fee": "0"
},
"message": "Record not found",
"success": false
}
1.4 Deployment and Interaction Example:
https://connect-nu-one.vercel.app/ (Open in DeBox)

Click each button to call the corresponding method, and observe the execution results in the "vConsole" at the bottom right.
Example Code:
// test the availability of deboxWallet
if (typeof window.deboxWallet !== "undefined") {
window.ethersProvider = new ethers.providers.Web3Provider(
window.deboxWallet
);
console.log("deboxWallet is available");
} else {
console.error("deboxWallet is not installed!");
}
console.log(
"window.ethersProvider ethers provider:",
window.ethersProvider
);
// eth_requestAccounts
async function connectWallet() {
console.log("window.deboxWallet", window.deboxWallet);
if (typeof window.deboxWallet !== "undefined") {
// connectButton.addEventListener("click", async () => {
try {
// Request account access if needed
const accounts = await window.deboxWallet.request({
method: "eth_requestAccounts",
});
console.log("eth_requestAccounts: ", accounts, typeof accounts);
// Display the connected wallet address
walletAddress.innerText = `Connected Wallet: ${accounts[0].slice(
0,
6
)}...${accounts[0].slice(-4)}`;
errorMessage.innerText = "";
requestPermissions();
} catch (error) {
// Handle error (e.g., user denied account access)
errorMessage.innerText =
"Error connecting wallet: " + error.message;
}
} else {
// If no wallet is installed
errorMessage.innerText =
"No Ethereum wallet found. Please install DeBoxWallet.";
}
}
// wallet_requestPermissions
async function requestPermissions() {
console.log("testSDK run wallet_requestPermissions");
if (typeof window.deboxWallet !== "undefined") {
try {
window.deboxWallet
.request({
method: "wallet_requestPermissions",
params: [
{
eth_accounts: {},
},
],
})
.then((response) => {
console.log(
"wallet_requestPermissions: ",
response,
typeof response
);
});
} catch (error) {
console.error(error);
alert(error.message);
}
} else {
// If no wallet is installed
errorMessage.innerText =
"No Ethereum wallet found. Please install DeBoxWallet.";
}
}
// requestPermissionsParams
async function requestPermissionsParams() {
console.log("testSDK run wallet_requestPermissions");
if (typeof window.deboxWallet !== "undefined") {
try {
window.deboxWallet
.request({
method: "wallet_requestPermissions",
params: [
{
eth_accounts: {
debox_getUserInfo: {},
debox_getVBoxBalance: {},
},
},
],
})
.then((response) => {
console.log(
"wallet_requestPermissions_params: ",
response,
typeof response
);
const item = response[0]; // []
const deboxUserInfo = item.caveats.find(
(caveat) => caveat.type === "debox_user_public_info"
);
if (deboxUserInfo) {
const avatar = deboxUserInfo
? deboxUserInfo.value.avatar
: null;
const name = deboxUserInfo ? deboxUserInfo.value.name : null;
const address = deboxUserInfo
? deboxUserInfo.value.address
: null;
const uid = deboxUserInfo ? deboxUserInfo.value.uid : null;
console.log(
"wallet_requestPermissions_params data",
response?.[0]?.caveats?.[1]
);
const imgElement = document.getElementById("walletAvatar");
imgElement.src = avatar;
walletNickName.innerText = `NickName: ${name}`;
walletAddress.innerText = `Connected Wallet: ${address?.slice(
0,
6
)}...${address?.slice(-4)}`;
walletUid.innerText = `uid: ${uid}`;
errorMessage.innerText = "";
}
});
} catch (error) {
console.error(error);
alert(error.message);
}
} else {
// If no wallet is installed
errorMessage.innerText =
"No Ethereum wallet found. Please install DeBoxWallet.";
}
}
// debox_getUserInfo
async function getUserInfo() {
console.log("testSDK run debox_getUserInfo");
window.deboxWallet
.request({
method: "debox_getUserInfo",
params: [],
})
.then((response) => {
console.log("debox_getUserInfo", response, typeof response);
if (response) {
const imgElement = document.getElementById("walletAvatarUser");
imgElement.src = response?.avatar;
walletNickNameUser.innerText = `NickName: ${response?.name}`;
walletAddressUser.innerText = `Connected Wallet: ${response?.address?.slice(
0,
6
)}...${response?.address?.slice(-4)}`;
walletUidUser.innerText = `uid: ${response?.uid}`;
errorMessage.innerText = "";
}
})
.catch((error) => {
console.error(error);
alert(error.message);
});
}
// debox_getVBoxBalance
async function getVBoxBalance() {
console.log("testSDK run debox_getVBoxBalance");
window.deboxWallet
.request({
method: "debox_getVBoxBalance",
params: [],
})
.then((response) => {
console.log("debox_getVBoxBalance", response, typeof response);
walletAddressBalance.innerText = `vBOX: ${response?.usable_balance}`;
})
.catch((error) => {
console.error(error);
alert(error.message);
});
}
// debox_paymentVBox
async function paymentVBox() {
console.log("testSDK run debox_paymentVBox");
if (typeof window.deboxWallet !== "undefined") {
const walletUid = document.getElementById("walletUid");
const addressInput = document.getElementById("addressInput");
const amountInput = document.getElementById("amountInput");
const donationAmountInput = document.getElementById(
"donationAmountInput"
);
const noteInput = document.getElementById("noteInput");
let receiver_address = addressInput.value;
let amount = amountInput.value;
let donation_amount = donationAmountInput.value;
let note = noteInput.value;
console.log(walletUid.innerText, amount, donation_amount, note);
if (!receiver_address) {
alert("Please enter receiver");
return;
}
window.deboxWallet
.request({
method: "debox_paymentVBox",
params: [
{
receiver_address: receiver_address, // address of the receiver
amount: amount || 0.01, // amount of payment, minimum 0.01
// nonce: 0, // integer, optional
note: note || "buy a cup of coffee in the game",
donation_amount: donation_amount || 40,
},
],
})
.then((response) => {
console.log("debox_paymentVBox", response, typeof response);
orderIdShow.innerText = `${response?.order_id}`;
})
.catch((error) => {
console.error(error);
alert(error.message);
});
} else {
errorMessage.innerText =
"No Ethereum wallet found. Please install DeBoxWallet.";
}
}
2. On-Chain Payment Integration with Shares
On-chain payment is a real-time shares distribution method. When users make payments using tokens, a portion of the payment amount is automatically donated to the DeBox Shares protocol for shares distribution, completing the revenue sharing process.
2.1 On-Chain Payment Shares Process
There are two types of on-chain payment shares: native token (ETH) payment shares and ERC20 token payment shares:
2.1.1 Native Token (ETH) Payment Shares
The native token (ETH) payment shares involves two steps: calculating the shares amount and calling the contract's donation function to trigger subsequent processing.
-
Calculate the Shares Amount
- The Dapp calculates the shares amount to be distributed through the DeBox Shares protocol based on the business design.
-
Call the
donationToShares
Method with the Shares Amount to Trigger Subsequent Logic:- After calculating the shares amount, the Dapp calls the DeBox Shares contract's
donationToShares
method to officially distribute the calculated amount.
// ...
uint256 donatedAmountETH = amountAcquiredETH / 10; // Calculate the shares amount
doxShares.donationToShares{ value: donatedAmountETH }(); // Trigger subsequent shares logic
// ... - After calculating the shares amount, the Dapp calls the DeBox Shares contract's
-
Example Contract Logic
-
Example of a Dapp contract integrating the Shares protocol:
// SPDX-License-Identifier: Apache License 2.0
pragma solidity ^0.8.22;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IDeBoxShares } from "@debox/deboxdapp/interfaces/facets/IShares.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
contract PlayGameWithShares {
IDeBoxShares public doxShares;
event GamePlayed(address player, IERC20 token, uint256 amount);
constructor(IDeBoxShares _doxShares) {
doxShares = _doxShares;
}
// ETH payment function integrated with the Shares protocol in the Dapp
function playGameWithETH() external payable {
uint256 amount = msg.value;
uint256 donatedAmount = amount / 10;
if (donatedAmount > 0) {
doxShares.donationToShares{ value: donatedAmount }();
}
emit GamePlayed(msg.sender, IERC20(address(0)), amount);
}
}
2.1.2 ERC20 Token Payment Shares
The ERC20 token payment shares involves two steps: calculating the shares amount and authorizing the DeBox Shares contract, and calling the contract's donation function to trigger subsequent processing.
-
Calculate the Shares Amount and Authorize the DeBox Shares Contract
- First, the Dapp transfers the user's payment tokens to the Dapp contract and calculates the shares amount to be distributed through the DeBox Shares protocol based on the business design.
- Then, the contract calls the
safeIncreaseAllowance
method to authorize the DeBox Shares contract address to use the shares amount.
// ...
SafeERC20.safeTransferFrom(token, msg.sender, address(this), amount); // Transfer the user's payment tokens to the Dapp contract
uint256 donatedAmount = amountAcquired / 10; // Calculate the shares amount to be distributed through the DeBox Shares protocol
SafeERC20.safeIncreaseAllowance(token, address(doxShares), donatedAmount); // Authorize the DeBox Shares contract to use the shares amount
// ... -
Call the
donationToShares
Method to Trigger Subsequent Shares Logic- After authorizing the shares amount, the contract calls the DeBox Shares contract's
donationToShares
method to officially distribute the calculated amount. - This method triggers the subsequent processing logic of the DeBox Shares protocol, transferring the shares amount to the DAO asset pool or distributing it to beneficiaries.
// ...
// The above logic for calculating the shares amount and authorizing the contract
// ...
doxShares.donationToShares(token, donatedAmount); // Trigger subsequent shares logic
// ... - After authorizing the shares amount, the contract calls the DeBox Shares contract's
-
Example Contract Logic
-
Example of a Dapp contract integrating the Shares protocol:
// SPDX-License-Identifier: Apache License 2.0
pragma solidity ^0.8.22;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IDeBoxShares } from "@debox/deboxdapp/interfaces/facets/IShares.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
contract PlayGameWithShares {
IDeBoxShares public doxShares;
event GamePlayed(address player, IERC20 token, uint256 amount);
constructor(IDeBoxShares _doxShares) {
doxShares = _doxShares;
}
// ERC20 token payment function integrated with the Shares protocol in the Dapp
function playGame(IERC20 token, uint256 amount) external {
SafeERC20.safeTransferFrom(token, msg.sender, address(this), amount);
uint256 donatedAmount = amount / 10;
if (donatedAmount > 0) {
SafeERC20.safeIncreaseAllowance(token, address(doxShares), donatedAmount);
doxShares.donationToShares(address(token), donatedAmount);
}
emit GamePlayed(msg.sender, token, amount);
}
2.2 Shares Contract Interface:
-
DeBox-Shares contract interface:
// SPDX-License-Identifier: Apache License 2.0
pragma solidity ^0.8.22;
interface IDeBoxShares {
event DonationToShares(address indexed contributor, address indexed token, uint256 amount);
event SharesConfigSet(address vault, address weth);
/**
* @notice Donate tokens to the shares protocol.
* @dev The donated tokens will be transferred to the vault.
* before the donation, the caller must approve me to spend the token.
* @param token The token to donate. must be a valid ERC20 token.
* @param amount The amount of `token` to donate. must be greater than 0.
*/
function donationToShares(address token, uint256 amount) external;
/**
* @notice Donate Native coin (ETH) to the shares protocol.
*/
function donationToShares() external payable;
function getSharesConfig() external view returns (address vault, address weth);
}
2.3 DeBox-Shares Contract Deployment Addresses:
Network | Contract Address |
---|---|
Ethereum | 0x2e6168f9ca3fe204a2110c4613ce18985f3fbf39 |
Arbitrum One | 0x509Ca4ff42cECAA1FF4988514211b26e72BDa840 |
Base | 0x2f8Ae1cC4ab784f7b9E07A61F714ecDe18A4A6d2 |
BSC | 0x32303FFcb9B6564C2b8a373433A043a7f17E4B37 |
Optimism | 0x18574E5a838B3FE16948653873386DD114ba1D7C |
Polygon | 0xb8Af0Fa3E38E8Cb95870091b0d4e32CA232b780D |
2.4 Simplified On-Chain Shares Interface
For Dapps without complex business logic, DeBox provides a simplified on-chain shares interface that supports shares distribution during on-chain native token payments and ERC20 token payments.
Supported Methods:
-
payAndShareWithETH: This method is used for shares distribution during ETH payments.
- Contract Method:
/**
* @notice Pay with ETH and distribute shares, the recipient address and shares amount can be specified.
* @param recipient The target address receiving the ETH payment.
* @param shareAmount The amount of ETH used for Shares, a part of the total ETH payment.
*/
function payAndShareWithETH(address payable recipient, uint256 shareAmount) external payable;- Contract Method Call Example:
contract Example {
function examplePayAndShare(address payable recipient) external payable {
// Assume paying 1 ETH, with 0.2 ETH for shares
payAndShareWithETH{value: 1 ether}(recipient, 0.2 ether);
// After the transaction, the recipient receives 0.8 ETH, and 0.2 ETH is distributed through the Shares protocol
}
}- ABI Specification:
[
{
"type": "function",
"name": "payAndShareWithETH",
"inputs": [
{
"name": "recipient",
"type": "address",
"internalType": "address payable"
},
{
"name": "shareAmount",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "payable"
}
]- ABI Call Example (based on ethers.js)
const { ethers } = require("ethers");
// Assume contract address and ABI
const contractAddress = "SimplifiedSharesContractDeploymentAddress";
const abi = [
{
"type": "function",
"name": "payAndShareWithETH",
"inputs": [
{ "name": "recipient", "type": "address" },
{ "name": "shareAmount", "type": "uint256" }
],
"outputs": [],
"stateMutability": "payable"
}
];
// Set up Provider and Signer
const provider = new ethers.providers.JsonRpcProvider("https://your-rpc-url");
const signer = provider.getSigner();
const contract = new ethers.Contract(contractAddress, abi, signer);
// Call method
async function callPayAndShare() {
const recipient = "0xRecipientAddress";
const shareAmount = ethers.utils.parseEther("0.2");
const totalAmount = ethers.utils.parseEther("1.0");
const tx = await contract.payAndShareWithETH(recipient, shareAmount, {
value: totalAmount
});
console.log("Transaction sent:", tx.hash);
// Wait for transaction to complete
const receipt = await tx.wait();
console.log("Transaction mined:", receipt.transactionHash);
}
callPayAndShare(); -
payAndShareWithERC20: This method is used for shares distribution during ERC20 token payments.
- Contract Method:
/**
* @notice Pay with ERC20 tokens and distribute shares, specifying the recipient address, token address, and shares amount.
* @param recipient The target address receiving the ERC20 token payment.
* @param tokenAddress The contract address of the ERC20 token used for payment.
* @param amount The total amount of ERC20 tokens to be paid.
* @param shareAmount The amount of ERC20 tokens, used for Shares, a part of the total payment.
*/
function payAndShareWithERC20(address recipient, address tokenAddress, uint256 amount, uint256 shareAmount) external;- Contract Method Call Example:
contract Example {
function examplePayAndShareWithERC20(address recipient, address tokenAddress) external {
// Assume paying 1000 tokens, with 200 tokens for shares
payAndShareWithERC20(recipient, tokenAddress, 1000, 200);
// After the transaction, the recipient receives 800 tokens, and 200 tokens are distributed through the Shares protocol
}
}- ABI Specification:
[
{
"type": "function",
"name": "payAndShareWithERC20",
"inputs": [
{
"name": "recipient",
"type": "address",
"internalType": "address"
},
{
"name": "tokenAddress",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "shareAmount",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable"
}
]- ABI Call Example (based on ethers.js)
const { ethers } = require("ethers");
// Contract address and ABI
const contractAddress = "SimplifiedSharesContractDeploymentAddress";
const abi = [
{
"type": "function",
"name": "payAndShareWithERC20",
"inputs": [
{ "name": "recipient", "type": "address" },
{ "name": "tokenAddress", "type": "address" },
{ "name": "amount", "type": "uint256" },
{ "name": "shareAmount", "type": "uint256" }
],
"outputs": [],
"stateMutability": "nonpayable"
}
];
// Initialize Provider and Signer
const provider = new ethers.providers.JsonRpcProvider("https://your-rpc-url");
const signer = provider.getSigner();
const contract = new ethers.Contract(contractAddress, abi, signer);
async function callPayAndShareWithERC20() {
const recipient = "0xRecipientAddress";
const tokenAddress = "0xTokenAddress";
const amount = ethers.utils.parseUnits("1000", 18); // Assume the token has 18 decimals
const shareAmount = ethers.utils.parseUnits("200", 18);
const tx = await contract.payAndShareWithERC20(
recipient,
tokenAddress,
amount,
shareAmount
);
console.log("Transaction sent:", tx.hash);
// Wait for transaction to complete
const receipt = await tx.wait();
console.log("Transaction mined:", receipt.transactionHash);
}
callPayAndShareWithERC20();
Simplified Shares Contract Deployment Address:
Network | Contract Address |
---|---|
BSC | 0xf0Cc35840394eD6274e058620FC6eb3aBA27Ba2d |
2.5 Deployment and Interaction Example:
https://connect-nu-one.vercel.app/op_.html (Open in DeBox)

Click each button to call the corresponding method, and observe the execution results in the "vConsole" at the bottom right.