dapp/lp/defi/nft流动性质押挖矿稳定版,dapp/lp/defi/nft流动性质押挖矿分红系统开发详细案例及功能

简介:   Debit and credit voucher:When you deposit a token in Compound,you will get a credit voucher cToken.cToken is the ownership of the user's pledge token.You can exchange the original token and withdraw the corresponding profits in the Compound agreement.

  Debit and credit voucher:When you deposit a token in Compound,you will get a credit voucher cToken.cToken is the ownership of the user's pledge token.You can exchange the original token and withdraw the corresponding profits in the Compound agreement.

  LP voucher:The user will get the LP voucher Uni-XXX by depositing the token into Uniswap.The LP voucher is the ownership and usufruct certificate of the user's market making.

  With these vouchers,users can obtain profit distribution,making the tokens in their hands continue to grow.Liquidity mining goes further,adding new revenue incentives on the basis of the original revenue,which can motivate users to use the DeFi application.

  部署的合约:Multicall.sol

  /**

  *Submitted for verification at Etherscan.io on 2019-06-10

  */

  pragma solidity>=0.5.0;

  pragma experimental ABIEncoderV2;

  //SPDX-License-Identifier:GPL-3.0

  ///title Multicall-Aggregate results from multiple read-only function calls

  ///author Michael Elliot<mike makerdao.com>

  ///author Joshua Levine<joshua makerdao.com>

  ///author Nick Johnson<arachnid notdot.net>

  contract Multicall{

  struct Call{

  address target;

  bytes callData;

  }

  function aggregate(Call[]memory calls)public returns(uint256 blockNumber,bytes[]memory returnData){

  blockNumber=block.number;

  returnData=new bytes[](calls.length);

  for(uint256 i=0;i<calls.length;i++){

  (bool success,bytes memory ret)=calls<i>.target.call(calls<i>.callData);

  require(success);

  returnData<i>=ret;

  }

  }

  //Helper functions

  function getEthBalance(address addr)public view returns(uint256 balance){

  balance=addr.balance;

  }

  function getBlockHash(uint256 blockNumber)public view returns(bytes32 blockHash){

  blockHash=blockhash(blockNumber);

  }

  function getLastBlockHash()public view returns(bytes32 blockHash){

  blockHash=blockhash(block.number-1);

  }

  function getCurrentBlockTimestamp()public view returns(uint256 timestamp){

  timestamp=block.timestamp;

  }

  function getCurrentBlockDifficulty()public view returns(uint256 difficulty){

  difficulty=block.difficulty;

  }

  function getCurrentBlockGasLimit()public view returns(uint256 gaslimit){

  gaslimit=block.gaslimit;

  }

  function getCurrentBlockCoinbase()public view returns(address coinbase){

  coinbase=block.coinbase;

  }

  }

  js调用合约

  //引入web3

  const Web3=require('web3');

  const web3=new Web3('http://192.168.75.129:8545');

  //部署合约的abi

  const abi=[

  {

  "constant":false,

  "inputs":[

  {

  "components":[

  {

  "internalType":"address",

  "name":"target",

  "type":"address"

  },

  {

  "internalType":"bytes",

  "name":"callData",

  "type":"bytes"

  }

  ],

  "internalType":"struct Multicall.Call[]",

  "name":"calls",

  "type":"tuple[]"

  }

  ],

  "name":"aggregate",

  "outputs":[

  {

  "internalType":"uint256",

  "name":"blockNumber",

  "type":"uint256"

  },

  {

  "internalType":"bytes[]",

  "name":"returnData",

  "type":"bytes[]"

  }

  ],

  "payable":false,

  "stateMutability":"nonpayable",

  "type":"function"

  },

  {

  "constant":true,

  "inputs":[

  {

  "internalType":"uint256",

  "name":"blockNumber",

  "type":"uint256"

  }

  ],

  "name":"getBlockHash",

  "outputs":[

  {

  "internalType":"bytes32",

  "name":"blockHash",

  "type":"bytes32"

  }

  ],

  "payable":false,

  "stateMutability":"view",

  "type":"function"

  },

  {

  "constant":true,

  "inputs":[],

  "name":"getCurrentBlockCoinbase",

  "outputs":[

  {

  "internalType":"address",

  "name":"coinbase",

  "type":"address"

  }

  ],

  "payable":false,

  "stateMutability":"view",

  "type":"function"

  },

  {

  "constant":true,

  "inputs":[],

  "name":"getCurrentBlockDifficulty",

  "outputs":[

  {

  "internalType":"uint256",

  "name":"difficulty",

  "type":"uint256"

  }

  ],

  "payable":false,

  "stateMutability":"view",

  "type":"function"

  },

  {

  "constant":true,

  "inputs":[],

  "name":"getCurrentBlockGasLimit",

  "outputs":[

  {

  "internalType":"uint256",

  "name":"gaslimit",

  "type":"uint256"

  }

  ],

  "payable":false,

  "stateMutability":"view",

  "type":"function"

  },

  {

  "constant":true,

  "inputs":[],

  "name":"getCurrentBlockTimestamp",

  "outputs":[

  {

  "internalType":"uint256",

  "name":"timestamp",

  "type":"uint256"

  }

  ],

  "payable":false,

  "stateMutability":"view",

  "type":"function"

  },

  {

  "constant":true,

  "inputs":[

  {

  "internalType":"address",

  "name":"addr",

  "type":"address"

  }

  ],

  "name":"getEthBalance",

  "outputs":[

  {

  "internalType":"uint256",

  "name":"balance",

  "type":"uint256"

  }

  ],

  "payable":false,

  "stateMutability":"view",

  "type":"function"

  },

  {

  "constant":true,

  "inputs":[],

  "name":"getLastBlockHash",

  "outputs":[

  {

  "internalType":"bytes32",

  "name":"blockHash",

  "type":"bytes32"

  }

  ],

  "payable":false,

  "stateMutability":"view",

  "type":"function"

  }

  ];

  //部署到链上的合约的地址

  const address='0xd573A1f062751A4f947f1769B5D78c1815420bf9';

  //通过new web3.eth.Contract(abi,address)动态创建一个合约实例

  let MyContract=new web3.eth.Contract(abi,address);

  //getEthBalance方法是合约中的方法,methods为调取合约方法的内置方法

  MyContract.methods.getEthBalance('0x88ded3010c9e9b2b2d1914b07c0d674281952d19').call().then(console.log);

相关文章
|
新零售 数据可视化 物联网
解决方案应用实例 |“数智”合作,阿里云助力良渚古城建设智慧景区
在如今文旅融合大背景下,如何运用技术手段加强对文化遗产保护和利用已成为重要课题。阿里云所沉淀的云计算、数据驱动、人工智能等方面的先进技术,协助良渚古城遗址公园实现了数据资源的综合应用、深度应用和本地化应用,为游客提供全方位的便捷服务和体验,不断提高智能决策及精细化管理水平。良渚古城遗址公园与阿里云的“数智”合作,充分说明了只有运用云计算、大数据、互联网和物联网等技术,加快景区数字化进程,才能够更好地实现古代与当下的交相辉映。
4945 0
解决方案应用实例 |“数智”合作,阿里云助力良渚古城建设智慧景区
|
算法
最小生成树
《基础犀利》
194 0
最小生成树
|
机器学习/深度学习 人工智能 自然语言处理
搜狗二季度财报解读:有扎实的现在,也有性感的未来
搜狗二季度财报解读:有扎实的现在,也有性感的未来
239 0
搜狗二季度财报解读:有扎实的现在,也有性感的未来
|
Linux
Linux环境下挂载硬盘
本文主要讲解在Linux环境下如何挂载新加的磁盘,并配置开机自动挂载
569 0
Linux环境下挂载硬盘
|
3天前
|
弹性计算 关系型数据库 微服务
基于 Docker 与 Kubernetes(K3s)的微服务:阿里云生产环境扩容实践
在微服务架构中,如何实现“稳定扩容”与“成本可控”是企业面临的核心挑战。本文结合 Python FastAPI 微服务实战,详解如何基于阿里云基础设施,利用 Docker 封装服务、K3s 实现容器编排,构建生产级微服务架构。内容涵盖容器构建、集群部署、自动扩缩容、可观测性等关键环节,适配阿里云资源特性与服务生态,助力企业打造低成本、高可靠、易扩展的微服务解决方案。
1101 0
|
2天前
|
机器学习/深度学习 人工智能 前端开发
通义DeepResearch全面开源!同步分享可落地的高阶Agent构建方法论
通义研究团队开源发布通义 DeepResearch —— 首个在性能上可与 OpenAI DeepResearch 相媲美、并在多项权威基准测试中取得领先表现的全开源 Web Agent。
462 9
|
12天前
|
人工智能 运维 安全
|
11天前
|
人工智能 测试技术 API
智能体(AI Agent)搭建全攻略:从概念到实践的终极指南
在人工智能浪潮中,智能体(AI Agent)正成为变革性技术。它们具备自主决策、环境感知、任务执行等能力,广泛应用于日常任务与商业流程。本文详解智能体概念、架构及七步搭建指南,助你打造专属智能体,迎接智能自动化新时代。
|
3天前
|
弹性计算 Kubernetes jenkins
如何在 ECS/EKS 集群中有效使用 Jenkins
本文探讨了如何将 Jenkins 与 AWS ECS 和 EKS 集群集成,以构建高效、灵活且具备自动扩缩容能力的 CI/CD 流水线,提升软件交付效率并优化资源成本。
296 0
|
10天前
|
人工智能 异构计算
敬请锁定《C位面对面》,洞察通用计算如何在AI时代持续赋能企业创新,助力业务发展!
敬请锁定《C位面对面》,洞察通用计算如何在AI时代持续赋能企业创新,助力业务发展!