openseaNFT 铸造交易平台系统开发模式方案
NFT,188智能1928系统开发8024,事务及事件信息传入智能合约后,合约资源集合中的资源状态会被更新,进而触发智能合约进行状态机判断。如果自动状态机中某个或某几个动作的触发条件满足,则由状态机根据预设信息选择合约动作自动执行
基于区块链的智能合约包括事务处理和保存的机制,以及一个完备的状态机,用于接受和处理各种智能合约;并且事务的保存和状态处理都在区块链上完成。事务主要包含需要发送的数据;而事件则是对这些数据的描述信息。
_safeMint(_toAddress,newItemId);
_setTokenURI(newItemId,_uri);
emit Minted(_toAddress,_price,newItemId,_uri);
return newItemId;
}
}
const{web3}=require("openzeppelin/test-environment");
const{expect}=require("chai");
const{BigNumber}=require("bignumber.js");
const TestNFTContract=artifacts.require("TestNFT");
contract("TestNFT",(accounts)=>{
describe("testnft",()=>{
beforeEach(async()=>{
thi***ntract=await TestNFTContract.new({from:accounts[0]});
});
it("It should mint NFT successfully",async()=>{
const tokenURI="ipfs://QmXzG9HN8Z4kFE2yHF81Vjb3xDYu53tqhRciktrt25JpAN";
const mintResult=await thi***ntract.mintNFT(
tokenURI,
accounts[0],
web3.utils.toWei("12","ether"),
{from:accounts[0]}
);
contract TestNFT is ERC721URIStorage,Ownable{
using Counters for Cou***unter;
Cou***unter private _tokenIds;
mapping(uint=>uint)public priceMap;
event Minted(address indexed minter,uint price,uint nftID,string uri);
constructor()ERC721("TestNFT","NFT"){}
function mintNFT(string memory _uri,address _toAddress,uint _price)public onlyOwner returns(uint256){
_tok***crement();
uint256 newItemId=_tokenIds.current();
priceMap[newItemId]=_price;
console.log(mintResult);
const price=web3.utils.fromWei(
new BigNumber(mintResult.logs[1].args.price).toString(),
"ether"
基于区块链的智能合约包括事务处理和保存的机制,以及一个完备的状态机,用于接受和处理各种智能合约;并且事务的保存和状态处理都在区块链上完成。事务主要包含需要发送的数据;而事件则是对这些数据的描述信息。
_safeMint(_toAddress,newItemId);
_setTokenURI(newItemId,_uri);
emit Minted(_toAddress,_price,newItemId,_uri);
return newItemId;
}
}
const{web3}=require("openzeppelin/test-environment");
const{expect}=require("chai");
const{BigNumber}=require("bignumber.js");
const TestNFTContract=artifacts.require("TestNFT");
contract("TestNFT",(accounts)=>{
describe("testnft",()=>{
beforeEach(async()=>{
thi***ntract=await TestNFTContract.new({from:accounts[0]});
});
it("It should mint NFT successfully",async()=>{
const tokenURI="ipfs://QmXzG9HN8Z4kFE2yHF81Vjb3xDYu53tqhRciktrt25JpAN";
const mintResult=await thi***ntract.mintNFT(
tokenURI,
accounts[0],
web3.utils.toWei("12","ether"),
{from:accounts[0]}
);
contract TestNFT is ERC721URIStorage,Ownable{
using Counters for Cou***unter;
Cou***unter private _tokenIds;
mapping(uint=>uint)public priceMap;
event Minted(address indexed minter,uint price,uint nftID,string uri);
constructor()ERC721("TestNFT","NFT"){}
function mintNFT(string memory _uri,address _toAddress,uint _price)public onlyOwner returns(uint256){
_tok***crement();
uint256 newItemId=_tokenIds.current();
priceMap[newItemId]=_price;
console.log(mintResult);
const price=web3.utils.fromWei(
new BigNumber(mintResult.logs[1].args.price).toString(),
"ether"