{"id":22915065,"url":"https://github.com/stratisproject/stratis.smartcontracts.testchain","last_synced_at":"2025-08-23T10:13:25.122Z","repository":{"id":54551101,"uuid":"164778103","full_name":"stratisproject/Stratis.SmartContracts.TestChain","owner":"stratisproject","description":"A C# library to help with local testing of smart contracts.","archived":false,"fork":false,"pushed_at":"2021-02-11T05:35:58.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-01T11:55:12.606Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stratisproject.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-09T03:13:55.000Z","updated_at":"2022-06-30T14:04:36.000Z","dependencies_parsed_at":"2022-08-13T19:20:56.160Z","dependency_job_id":null,"html_url":"https://github.com/stratisproject/Stratis.SmartContracts.TestChain","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stratisproject/Stratis.SmartContracts.TestChain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stratisproject%2FStratis.SmartContracts.TestChain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stratisproject%2FStratis.SmartContracts.TestChain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stratisproject%2FStratis.SmartContracts.TestChain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stratisproject%2FStratis.SmartContracts.TestChain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stratisproject","download_url":"https://codeload.github.com/stratisproject/Stratis.SmartContracts.TestChain/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stratisproject%2FStratis.SmartContracts.TestChain/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271746559,"owners_count":24813570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-14T05:18:36.132Z","updated_at":"2025-08-23T10:13:25.096Z","avatar_url":"https://github.com/stratisproject.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stratis.SmartContracts.TestChain\n\nA C# library to help with local testing of smart contracts.\n\nSee below for an example of how to use this tool in code.\n\n```cs\nusing Stratis.Bitcoin.Features.SmartContracts.Models;\nusing Stratis.SmartContracts.CLR.Compilation;\nusing Stratis.SmartContracts.CLR.Local;\nusing Xunit;\n\nnamespace Stratis.SmartContracts.TestChain.Tests\n{\n    public class TestChainExample\n    {\n        [Fact]\n        public void TestChain_Auction()\n        {\n            // Compile the contract we want to deploy\n            ContractCompilationResult compilationResult = ContractCompiler.CompileFile(\"SmartContracts/Auction.cs\");\n            Assert.True(compilationResult.Success);\n\n            using (TestChain chain = new TestChain().Initialize())\n            {\n                // Get an address we can use for deploying\n                Base58Address deployerAddress = chain.PreloadedAddresses[0];\n\n                // Create and send transaction to mempool with parameters\n                SendCreateContractResult createResult = chain.SendCreateContractTransaction(deployerAddress, compilationResult.Compilation, 0, new object[] { 20uL });\n\n                // Mine a block which will contain our sent transaction\n                chain.MineBlocks(1);\n\n                // Check the receipt to see that contract deployment was successful\n                ReceiptResponse receipt = chain.GetReceipt(createResult.TransactionId);\n                Assert.Equal(deployerAddress, receipt.From);\n\n                // Check that the code is indeed saved on-chain\n                byte[] savedCode = chain.GetCode(createResult.NewContractAddress);\n                Assert.NotNull(savedCode);\n\n                // Use another identity to bid\n                Base58Address bidderAddress = chain.PreloadedAddresses[1];\n\n                // Send a call to the bid method\n                SendCallContractResult callResult = chain.SendCallContractTransaction(bidderAddress, \"Bid\", createResult.NewContractAddress, 1);\n                chain.MineBlocks(1);\n\n                // Call a method locally to check the state is as expected\n                ILocalExecutionResult localCallResult = chain.CallContractMethodLocally(bidderAddress, \"HighestBidder\", createResult.NewContractAddress, 0);\n                Address storedHighestBidder = (Address)localCallResult.Return;\n                Assert.NotEqual(default(Address), storedHighestBidder); // TODO: A nice way of comparing hex and base58 representations\n            }\n        }\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstratisproject%2Fstratis.smartcontracts.testchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstratisproject%2Fstratis.smartcontracts.testchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstratisproject%2Fstratis.smartcontracts.testchain/lists"}