public async void ShouldDeployCustomAndQueryInteractWithGenericService() { var web3 = _ethereumClientIntegrationFixture.GetWeb3(); web3.Eth.TransactionManager.UseLegacyAsDefault = true; var erc721Deployment = new MyERC721Deployment() { Name = "Property Registry", Symbol = "PR" }; var deploymentReceipt = await web3.Eth.GetContractDeploymentHandler <MyERC721Deployment>().SendRequestAndWaitForReceiptAsync(erc721Deployment); //creating a new service with the new contract address var erc721Service = web3.Eth.GetERC721Service(deploymentReceipt.ContractAddress); var url = "ipfs://bafkreiblz4ltiepapdhqhjiurmfpov7extmxwcntqskvx2zqisoftlmk7a"; var addressToRegisterOwnership = "0xe612205919814b1995D861Bdf6C2fE2f20cDBd68"; var mintReceipt = await erc721Service.SafeMintRequestAndWaitForReceiptAsync(web3.TransactionManager.Account.Address, url); var ownerOfToken = await erc721Service.OwnerOfQueryAsync(0); Assert.True(ownerOfToken.IsTheSameAddress(web3.TransactionManager.Account.Address)); var addressOfToken = await erc721Service.TokenURIQueryAsync(0); Assert.Equal(url, addressOfToken); var transfer = await erc721Service.TransferFromRequestAndWaitForReceiptAsync(ownerOfToken, addressToRegisterOwnership, 0); Assert.False(transfer.HasErrors()); ownerOfToken = await erc721Service.OwnerOfQueryAsync(0); Assert.True(ownerOfToken.IsTheSameAddress(addressToRegisterOwnership)); }
public static async Task <MyERC721Service> DeployContractAndGetServiceAsync(Nethereum.Web3.Web3 web3, MyERC721Deployment myERC721Deployment, CancellationTokenSource cancellationTokenSource = null) { var receipt = await DeployContractAndWaitForReceiptAsync(web3, myERC721Deployment, cancellationTokenSource); return(new MyERC721Service(web3, receipt.ContractAddress)); }
public static Task <string> DeployContractAsync(Nethereum.Web3.Web3 web3, MyERC721Deployment myERC721Deployment) { return(web3.Eth.GetContractDeploymentHandler <MyERC721Deployment>().SendRequestAsync(myERC721Deployment)); }
public static Task <TransactionReceipt> DeployContractAndWaitForReceiptAsync(Nethereum.Web3.Web3 web3, MyERC721Deployment myERC721Deployment, CancellationTokenSource cancellationTokenSource = null) { return(web3.Eth.GetContractDeploymentHandler <MyERC721Deployment>().SendRequestAndWaitForReceiptAsync(myERC721Deployment, cancellationTokenSource)); }
public async void ShouldDeployAndMintNFTToken() { //Using rinkeby to demo opensea, if we dont want to use the configured client //please input your infura id in appsettings.test.json var web3 = _ethereumClientIntegrationFixture.GetInfuraWeb3(InfuraNetwork.Rinkeby); //var web3 = _ethereumClientIntegrationFixture.GetWeb3(); //if you want to use your local node (ie geth, uncomment this, see appsettings.test.json for further info) //example of configuration as legacy (not eip1559) to work on L2s web3.Eth.TransactionManager.UseLegacyAsDefault = true; //creating our deployment information (this includes the bytecode already) //This example creates an NFT Property (Real state) registry var erc721Deployment = new MyERC721Deployment() { Name = "Property Registry", Symbol = "PR" }; //Deploy the erc721Minter var deploymentReceipt = await MyERC721Service.DeployContractAndWaitForReceiptAsync(web3, erc721Deployment); //creating a new service with the new contract address var erc721Service = new MyERC721Service(web3, deploymentReceipt.ContractAddress); //uploading to ipfs our documents var nftIpfsService = new NFTIpfsService("https://ipfs.infura.io:5001"); var imageIpfs = await nftIpfsService.AddFileToIpfsAsync("Documents/TitlePlanImage.png"); var titleIpfs = await nftIpfsService.AddFileToIpfsAsync("Documents/example_title_plan.pdf"); var registerIpfs = await nftIpfsService.AddFileToIpfsAsync("Documents/example_register.pdf"); //adding all our document ipfs links to the metadata and the description var metadataNFT = new NFTPropertyRegistryMetadata() { Name = "CS72510: Property registry example", AddressOfProperty = "23 Cottage Lane, Kerwick, PL14 3JP", Image = "ipfs://" + imageIpfs.Hash, //The image is what is displayed in market places like opean sea TitleDocument = "ipfs://" + titleIpfs.Hash, RegisterDocument = "ipfs://" + registerIpfs.Hash, PlanReference = "SD4008", TitleNumber = "CS72510", MapReference = "SY6676NE", ExternalUrl = "https://github.com/Nethereum/ERC721ContractLibrary.Template" }; //Adding the metadata to ipfs var metadataIpfs = await nftIpfsService.AddNftsMetadataToIpfsAsync(metadataNFT, "PropertyRegistryMetadata.json"); var addressToRegisterOwnership = "0xe612205919814b1995D861Bdf6C2fE2f20cDBd68"; //Minting the nft with the url to the ipfs metadata var mintReceipt = await erc721Service.SafeMintRequestAndWaitForReceiptAsync( addressToRegisterOwnership, "ipfs://" + metadataIpfs.Hash); //we have just minted our first nft so the nft will have the id of 0. var ownerOfToken = await erc721Service.OwnerOfQueryAsync(0); Assert.True(ownerOfToken.IsTheSameAddress(addressToRegisterOwnership)); var addressOfToken = await erc721Service.TokenURIQueryAsync(0); Assert.Equal("ipfs://" + metadataIpfs.Hash, addressOfToken); //Url format https://testnets.opensea.io/assets/[nftAddress]/[id] //opening opensea testnet to visualise the nft var ps = new ProcessStartInfo("https://testnets.opensea.io/assets/" + deploymentReceipt.ContractAddress + "/0") { UseShellExecute = true, Verb = "open" }; Process.Start(ps); var transfer = await erc721Service.TransferFromRequestAndWaitForReceiptAsync(ownerOfToken, ownerOfToken, 0); Assert.False(transfer.HasErrors()); }