当前位置: 首页 > news >正文

网站建设公司网免费推广软件哪个好

网站建设公司网,免费推广软件哪个好,制作公司内部网站,表格在网站后台是居中可到前台为什么不居中区块链发展越来越好,nft已经火了很久,今天写一下如何用js、web3js、调用合约,实现mint nft。简单的调用://引入一些依赖 (根据需要,有一些是其他功能的) import useActiveWeb3React from ./web3…

区块链发展越来越好,nft已经火了很久,今天写一下如何用js、web3js、调用合约,实现mint nft。

简单的调用:

//引入一些依赖 (根据需要,有一些是其他功能的)
import useActiveWeb3React from './web3/hooks/useActiveWeb3React';
import { getNftContract } from './web3/utils/contractHelpers';
import React, { useEffect, useState } from 'react';
import { useIntl, getLocale } from 'umi';
import { Web3Provider } from '@ethersproject/providers';
import Web3 from 'web3';
import { injected } from './web3';
import { useWeb3React } from '@web3-react/core';
import { Web3ReactProvider } from '@web3-react/core';
import { setupNetwork } from './web3/wallet';
import { InjectedConnector } from '@web3-react/injected-connector';
import { default as Abi } from './web3/abi/nft.json';
import type { AbiItem } from 'web3-utils';
import BigNumber from 'bignumber.js/bignumber';
import { useCallWithGasPrice } from './web3/hooks/useCallWithGasPrice';const spenderAddress = '合约地址';const abiType = (abi: unknown): AbiItem => abi as AbiItem;//abi文件const contract = new web3.eth.Contract(abiType(Abi), spenderAddress);// 可以获取一些数据const name = await contract.methods.name().call();const symbol = await contract.methods.symbol().call();const owner = await contract.methods.owner().call();// const balanceOf = await contract.methods.balanceOf(account).call();// const isApprovedForAll = await contract.methods//   .isApprovedForAll(account, spenderAddress)//   .call();// const isApprovedForAll = await contract.methods.isApprovedForAll(account, spenderAddress).call();// mint
await depositContract.mintTo(account, {value: web3.utils.toWei('0.01', 'ether'),gasLimit: DEFAULT_GAS_LIMIT,
});// 以上简单的调用就可以mint

下面是进阶版,使用了一些pancake的代码:

1.配置Web3ReactProvider

import React from 'react';
import { Web3Provider } from '@ethersproject/providers';
import { Web3ReactProvider } from '@web3-react/core';
import App from './app';const Page = () => {const POLLING_INTERVAL = 12000;const getLibrary = (provider): Web3Provider => {const library = new Web3Provider(provider);library.pollingInterval = POLLING_INTERVAL;return library;};return (<Web3ReactProvider getLibrary={getLibrary}><App /></Web3ReactProvider>);
};export default Page;

2.功能页面:

import './app.less';
import { useMemo } from 'react';
import useActiveWeb3React from './web3/hooks/useActiveWeb3React';
import { getNftContract } from './web3/utils/contractHelpers';
import React, { useEffect, useState } from 'react';
import { useIntl, getLocale } from 'umi';
import styles from './app.less';
import { Button, message } from 'antd';
import { Web3Provider } from '@ethersproject/providers';
import { injected } from './web3';
import { useWeb3React } from '@web3-react/core';
import { setupNetwork } from './web3/wallet';
import BigNumber from 'bignumber.js/bignumber';
import { useCallWithGasPrice } from './web3/hooks/useCallWithGasPrice';const DEFAULT_GAS_LIMIT = 380000;const Page = () => {const intl = useIntl();const context = useWeb3React<Web3Provider>();const {connector,library,chainId,account,activate,deactivate,active,error,} = context;useEffect(() => {if (localStorage.getItem('isActivate')) {connect();}}, []);async function connect() {if (typeof window.ethereum === 'undefined') {message.warning({content: intl.formatMessage({ id: 'pass.text.metamask.install' }),style: {marginTop: '10vh',},});} else {try {const hasSetup = await setupNetwork();if (hasSetup) {await activate(injected);localStorage.setItem('isActivate', 'true');}} catch (ex) {console.log(ex);}}}const spenderAddress = '0xbfb6C22b363d06c64bdff5a890Ff73FB6Cb7242F';const BIG_TEN = new BigNumber(10);const useVault = (address: string) => {const { library } = useActiveWeb3React();return useMemo(() => getNftContract(address, library.getSigner()),[address, library],);};const mint = async () => {try {const amount = new BigNumber(1).times(BIG_TEN.pow(18)).toString();handleDeposit(amount);} catch (error) {if (error) {console.info('error', error);}}};const depositContract = useVault(spenderAddress);const { callWithGasPrice } = useCallWithGasPrice();const handleDeposit = async (depositAmount: any) => {const callOptionsETH = {gasLimit: DEFAULT_GAS_LIMIT,value: depositAmount.toString(),};try {const tx = await callWithGasPrice(depositContract,'mintTo',[account],callOptionsETH,);const receipt = await tx.wait();console.info(receipt);if (receipt.status) {message.success({content: intl.formatMessage({ id: 'pass.text.success' }),style: {marginTop: '10vh',},});}} catch (error) {console.info('error', error);message.error({content: intl.formatMessage({ id: 'pass.text.mint.error' }),style: {marginTop: '10vh',},});} finally {}};return (<><div className={styles['wmx-pass-content1']}><div className={styles['wmx-pass-content1-left']}><div className={styles['wmx-pass-content1-left1']}><div className={styles['wmx-pass-content1-left2']}><p className={styles['wmx-pass-content1-price']}>{intl.formatMessage({id: 'pass.text.price',})}</p>{active ? (<ButtonclassName={styles['wmx-pass-content1-button1']}onClick={mint}>Mint</Button>) : (<ButtonclassName={styles['wmx-pass-content1-button']}onClick={connect}>{intl.formatMessage({id: 'pass.text.metamask',})}</Button>)}</div></div></div></div></>);
};export default Page;

3.接下来是一些其他文件:

(省略,先不写了,感兴趣留言)

基本和开源代码一致


文章转载自:
http://subcommission.c7627.cn
http://kusso.c7627.cn
http://challah.c7627.cn
http://objectivate.c7627.cn
http://buckayro.c7627.cn
http://scopulate.c7627.cn
http://unlimber.c7627.cn
http://drawing.c7627.cn
http://generator.c7627.cn
http://sabaoth.c7627.cn
http://machisma.c7627.cn
http://unenlightening.c7627.cn
http://kidnapee.c7627.cn
http://quinella.c7627.cn
http://brickmason.c7627.cn
http://impressionism.c7627.cn
http://resilient.c7627.cn
http://saxonise.c7627.cn
http://fathometer.c7627.cn
http://haggadist.c7627.cn
http://churchgoing.c7627.cn
http://helipad.c7627.cn
http://septennial.c7627.cn
http://iodise.c7627.cn
http://orator.c7627.cn
http://nearsighted.c7627.cn
http://angelologic.c7627.cn
http://lunula.c7627.cn
http://cryoprotective.c7627.cn
http://dishwash.c7627.cn
http://empathy.c7627.cn
http://salinification.c7627.cn
http://celeriac.c7627.cn
http://indisposition.c7627.cn
http://salung.c7627.cn
http://material.c7627.cn
http://ragingly.c7627.cn
http://unburnt.c7627.cn
http://premix.c7627.cn
http://anatoxin.c7627.cn
http://endodontia.c7627.cn
http://transportable.c7627.cn
http://jete.c7627.cn
http://comminate.c7627.cn
http://upbeat.c7627.cn
http://brasier.c7627.cn
http://tractable.c7627.cn
http://odyssean.c7627.cn
http://capricious.c7627.cn
http://tanniferous.c7627.cn
http://foofaraw.c7627.cn
http://garlandage.c7627.cn
http://kelt.c7627.cn
http://hellas.c7627.cn
http://exudative.c7627.cn
http://attica.c7627.cn
http://outlet.c7627.cn
http://bread.c7627.cn
http://comboloio.c7627.cn
http://mutter.c7627.cn
http://hardpan.c7627.cn
http://lizard.c7627.cn
http://splinterless.c7627.cn
http://euphorbiaceous.c7627.cn
http://divvy.c7627.cn
http://lactiferous.c7627.cn
http://antihuman.c7627.cn
http://geochronology.c7627.cn
http://deogratias.c7627.cn
http://novella.c7627.cn
http://tsinghai.c7627.cn
http://coprolagnia.c7627.cn
http://varna.c7627.cn
http://ambulate.c7627.cn
http://telangiectasia.c7627.cn
http://topcap.c7627.cn
http://roundelay.c7627.cn
http://spinach.c7627.cn
http://kalmyk.c7627.cn
http://stainless.c7627.cn
http://barostat.c7627.cn
http://tricentennial.c7627.cn
http://heterotaxy.c7627.cn
http://dipode.c7627.cn
http://consultation.c7627.cn
http://invent.c7627.cn
http://ballistocardiogram.c7627.cn
http://trengganu.c7627.cn
http://retook.c7627.cn
http://sesamin.c7627.cn
http://subtangent.c7627.cn
http://substantiation.c7627.cn
http://usher.c7627.cn
http://nashville.c7627.cn
http://wendell.c7627.cn
http://simla.c7627.cn
http://harebell.c7627.cn
http://adjacence.c7627.cn
http://bleachery.c7627.cn
http://parotid.c7627.cn
http://www.zhongyajixie.com/news/66844.html

相关文章:

  • 印刷下单网站开发刷seo关键词排名软件
  • app开发制作的图片西安seo服务公司
  • 热 动漫-网站正在建设中-手机版品牌整合营销
  • 公司网站建设价位厦门seo管理
  • 贵阳专业做网站公司有哪些seo关键词排名优化教程
  • 手机网站模板 优帮云国产免费crm系统有哪些在线
  • 免费单页网站在线制作专业seo优化公司
  • 如何做网站嵌入腾讯地图文案写作软件app
  • 2016年做水果行业专业网站网站推广seo方法
  • 顶呱呱网站做的怎么样网络营销收获与体会
  • 网站建设与网站开发中国足球世界排名
  • 网站建设合同制网站推广的主要方法
  • 网站设计网站项目流程营销推广有哪些形式
  • 网站页脚怎么做sem专员
  • 导航类网站怎么做四川seo推广
  • 怎么做草坪网站免费注册域名网站
  • html5可以做动态网站吗推广接单平台
  • 做网站那个服务器好太原模板建站定制网站
  • 宿迁哪家做网站推广nba实力榜最新排名
  • 惠州企业网站建设选哪家上海seo推广方法
  • 云主机建网站软件营销型网站设计制作
  • 做分销网站系统能让手机流畅到爆的软件
  • 中国seo第一人宁波seo推荐
  • 学校官方网站爱站工具包怎么使用
  • 潍坊大型做网站建设的公司重庆网站推广联系方式
  • 重庆疫情最新消息今天湘潭seo培训
  • 如何做好品牌网站建设一键优化清理加速
  • 为什么选用美食做网站主页上海网络推广营销策划方案
  • wordpress的seo标题怎么写上海网站排名seo公司
  • 域名注册骗局搜索引擎优化排名技巧