Compare commits

...

2 Commits
master ... dev

Author SHA1 Message Date
zzy 6f5fe26013 添加api 2022-06-06 16:46:07 +08:00
gary 1ab555f1b2 feat: 提交lock文件 2022-05-31 17:09:31 +08:00
5 changed files with 10375 additions and 180 deletions

1
.gitignore vendored
View File

@ -4,7 +4,6 @@
/node_modules /node_modules
/npm-debug.log* /npm-debug.log*
/yarn-error.log /yarn-error.log
/yarn.lock
/package-lock.json /package-lock.json
# production # production

View File

@ -1,196 +1,28 @@
[ [
{ {
"constant": true,
"inputs": [], "inputs": [],
"name": "name",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_spender",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "constructor"
},
{
"constant": true,
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_from",
"type": "address"
},
{
"name": "_to",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "decimals",
"outputs": [
{
"name": "",
"type": "uint8"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_owner",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"name": "balance",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_to",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_owner",
"type": "address"
},
{
"name": "_spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"payable": true,
"stateMutability": "payable",
"type": "fallback"
}, },
{ {
"anonymous": false, "anonymous": false,
"inputs": [ "inputs": [
{ {
"indexed": true, "indexed": true,
"internalType": "address",
"name": "owner", "name": "owner",
"type": "address" "type": "address"
}, },
{ {
"indexed": true, "indexed": true,
"name": "spender", "internalType": "address",
"name": "approved",
"type": "address" "type": "address"
}, },
{ {
"indexed": false, "indexed": true,
"name": "value", "internalType": "uint256",
"name": "tokenId",
"type": "uint256" "type": "uint256"
} }
], ],
@ -202,21 +34,690 @@
"inputs": [ "inputs": [
{ {
"indexed": true, "indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "operator",
"type": "address"
},
{
"indexed": false,
"internalType": "bool",
"name": "approved",
"type": "bool"
}
],
"name": "ApprovalForAll",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "minter",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "price",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "nftID",
"type": "uint256"
},
{
"indexed": false,
"internalType": "string",
"name": "uri",
"type": "string"
}
],
"name": "Minted",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "nftID",
"type": "uint256"
},
{
"indexed": false,
"internalType": "bool",
"name": "isListed",
"type": "bool"
}
],
"name": "NftListStatus",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "oldPrice",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "newPrice",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "nftID",
"type": "uint256"
}
],
"name": "PriceUpdate",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "price",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "nftID",
"type": "uint256"
},
{
"indexed": false,
"internalType": "string",
"name": "uri",
"type": "string"
}
],
"name": "Purchase",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from", "name": "from",
"type": "address" "type": "address"
}, },
{ {
"indexed": true, "indexed": true,
"internalType": "address",
"name": "to", "name": "to",
"type": "address" "type": "address"
}, },
{ {
"indexed": false, "indexed": true,
"name": "value", "internalType": "uint256",
"name": "tokenId",
"type": "uint256" "type": "uint256"
} }
], ],
"name": "Transfer", "name": "Transfer",
"type": "event" "type": "event"
},
{
"inputs": [],
"name": "_contractOwner",
"outputs": [
{
"internalType": "address payable",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "approve",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "baseURI",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_id",
"type": "uint256"
}
],
"name": "buy",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "getApproved",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "operator",
"type": "address"
}
],
"name": "isApprovedForAll",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "listedMap",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "_tokenURI",
"type": "string"
},
{
"internalType": "address",
"name": "_toAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "_price",
"type": "uint256"
}
],
"name": "mint",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "ownerOf",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "price",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "safeTransferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "_data",
"type": "bytes"
}
],
"name": "safeTransferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "operator",
"type": "address"
},
{
"internalType": "bool",
"name": "approved",
"type": "bool"
}
],
"name": "setApprovalForAll",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes4",
"name": "interfaceId",
"type": "bytes4"
}
],
"name": "supportsInterface",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "index",
"type": "uint256"
}
],
"name": "tokenByIndex",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "uint256",
"name": "index",
"type": "uint256"
}
],
"name": "tokenOfOwnerByIndex",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "tokenURI",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_tokenId",
"type": "uint256"
},
{
"internalType": "bool",
"name": "shouldBeListed",
"type": "bool"
}
],
"name": "updateListingStatus",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_tokenId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_price",
"type": "uint256"
}
],
"name": "updatePrice",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
} }
] ]

View File

@ -1,2 +1,2 @@
export const ACCOUNT = '0x6555e1cc97d3cba6eaddebbcd7ca51d75771e0b8'; export const ACCOUNT = '0xF75037b4b36B8d8ee21D83943A87d540E53760f1';
export const ETH_CONTRACT = '0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f'; export const ETH_CONTRACT = '0x1e58e4289996ed261ecf4d6df22ee0aa1c983c2b';

View File

@ -4,6 +4,8 @@ import ercAbi from '@/config/abi/erc20.json';
import { ACCOUNT, ETH_CONTRACT } from '@/config/constants'; import { ACCOUNT, ETH_CONTRACT } from '@/config/constants';
const IndexPage = () => { const IndexPage = () => {
const privateKey =
'2a5bc921f8887bdf3c5a0cb6ad6f65e16e1b0f4d797713439f7cc71e52eb100f';
const web3 = new Web3(Web3.givenProvider); const web3 = new Web3(Web3.givenProvider);
const myContract = new web3.eth.Contract(ercAbi, ETH_CONTRACT); const myContract = new web3.eth.Contract(ercAbi, ETH_CONTRACT);
const getBalance = async () => { const getBalance = async () => {
@ -11,11 +13,114 @@ const IndexPage = () => {
console.log('getBalance', res); console.log('getBalance', res);
}; };
// balanceOf
const contractCall = async () => { const contractCall = async () => {
const res = await myContract.methods.balanceOf(ACCOUNT).call();
console.log('contractCall', res);
};
const getGasPrice = async () => {
const res = await web3.eth.getGasPrice();
console.log('gasPrice = ', res);
return res;
};
// const get = async () => {
// const res = await myContract.methods.get('nana').call();
// console.log('contractCall', res);
// };
// const add = async () => {
// var functionEncode = await myContract.methods
// .add('nana', 'nnnn')
// .encodeABI();
// var sign = await web3.eth.accounts.signTransaction(
// {
// gas: 300000,
// to: ETH_CONTRACT,
// data: functionEncode,
// },
// privateKey,
// );
// var result = await web3.eth.sendSignedTransaction(sign.rawTransaction);
// console.log('setName txHash = ' + result.transactionHash);
// // console.log('result = ' + result);
// };
// const getTopics = async () => {
// var topic = web3.eth.abi.encodeFunctionSignature({
// inputs: [
// {
// internalType: 'string',
// name: '_tokenURI',
// type: 'string',
// },
// {
// internalType: 'address',
// name: '_toAddress',
// type: 'address',
// },
// {
// internalType: 'uint256',
// name: '_price',
// type: 'uint256',
// },
// ],
// name: 'mint',
// outputs: [
// {
// internalType: 'uint256',
// name: '',
// type: 'uint256',
// },
// ],
// stateMutability: 'nonpayable',
// type: 'function',
// });
// console.log('topic = ', topic);
// };
const getPastEvents = async () => {
var getPastEvents = await myContract.getPastEvents('AllEvents', {
fromBlock: 0, // 起始块
toBlock: 'latest', // 终止块
});
console.log('pastLogs = ', getPastEvents);
};
const mint = async () => {
var functionEncode = await myContract.methods
.mint(
'http://124.223.202.96:18088/6',
'0x75B79CE63b0AAc451FA125F591Ab2a16575d94A8',
1,
)
.encodeABI();
var sign = await web3.eth.accounts.signTransaction(
{
gas: 300000,
to: ETH_CONTRACT,
data: functionEncode,
chainId: 5,
},
privateKey,
);
var result = await web3.eth.sendSignedTransaction(sign.rawTransaction);
console.log('setName txHash = ' + result.transactionHash);
// console.log('result = ' + result);
};
const name = async () => {
const res = await myContract.methods.name().call(); const res = await myContract.methods.name().call();
console.log('contractCall', res); console.log('contractCall', res);
}; };
const tokenURI = async () => {
const res = await myContract.methods.tokenURI(2).call();
console.log('contractCall', res);
};
return ( return (
<div> <div>
<h2 className="title">ETH</h2> <h2 className="title">ETH</h2>
@ -27,6 +132,24 @@ const IndexPage = () => {
<Button type="primary" onClick={contractCall}> <Button type="primary" onClick={contractCall}>
</Button> </Button>
<Button type="primary" onClick={getGasPrice}>
gas价格
</Button>
<Button type="primary" onClick={getPastEvents}>
</Button>
<Button type="primary" onClick={mint}>
NTF-mint
</Button>
<Button type="primary" onClick={name}>
NTF名称-name
</Button>
<Button type="primary" onClick={tokenURI}>
NTF详情地址
</Button>
{/* <Button type="primary" onClick={getTopics}>
getTopics
</Button> */}
</Space> </Space>
<h3 className="part-title"></h3> <h3 className="part-title"></h3>
</div> </div>

9572
yarn.lock Normal file

File diff suppressed because it is too large Load Diff