Package: gscdk
Go Smart Contracts Development Kit (GSCDK)OverviewThe Go Smart Contracts Development Kit (GSCDK) provides a comprehensive toolkit for creating, building, and debugging Go-based smart contracts.Example of a Go Smart ContractHere is an example of what a Go Smart Contract looks like using GSCDK:packagemainimport("github.com/uuosio/chain")//table mytabletypeMyDatastruct{primaryuint64//primarynamestring}//contract mycontracttypeMyContractstruct{Receiverchain.NameFirstReceiverchain.NameActionchain.Name}funcNewContract(receiver,firstReceiver,actionchain.Name)*MyContract{return&MyContract{receiver,firstReceiver,action}}//action sayhellofunc(c*MyContract)SayHello(namestring){code:=c.Receiverpayer:=c.Receivermydb:=NewMyDataDB(code)primary:=uint64(111)ifit,data:=mydb.GetByKey(primary);it.IsOk(){ifdata.name!=name{chain.Println("Welcome new friend:",name)}else{chain.Println("Welcome old friend",name)}data.name=namemydb.Update(it,data,payer)}else{chain.Println("Welcome new friend",name)data:=&MyData{primary,name}mydb.Store(data,payer)}}Quick StartJump right into building your first smart contract with ourQuick Start Guide.InstallationTo install GSCDK, run the following command:For Unix-based platforms (like Linux or macOS):python3-mpipinstallgscdkFor Windows:python-mpipinstallgscdkUpgrading GSCDKIf you've previously installed GSCDK and want to upgrade to the latest version, use the following command:For Unix-based platforms:python3-mpipinstall--upgradegscdkFor Windows:python-mpipinstall--upgradegscdkBuilding Go Smart Contracts CompilerTo build thetinygocommand that supports building Go Smart Contracts, follow the instructions inBuilding. Once built, add thetinygocommand to your PATH:exportPATH=$(pwd)/compiler/build:$PATHUsing go-contractgo-contractis a powerful tool for managing your smart contract projects. Learn more about its features below:Initializing a ProjectUse the "init" command to initialize a project with a specific contract name:go-contractinitmycontractcdmycontractGenerating ABI and Extra CodeUse the "gencode" command to generate ABI and extra code for smart contracts:go-contractgencodeNote: Code generation is also the default option for the "build" command.Building Your ProjectTo compile the source code of your project, use the "build" command:go-contractbuildTo disable code generation during the build process, use the-gen-code=falseflag:go-contractbuild-gen-code=falseTo disable code optimization, use the-dor--debugoption:go-contractbuild-dDebuggingBefore debugging, installipyeos:python3-mpipinstallipyeosTo update to a new version, use the following command:python3-mpipinstall-UipyeosThen run the debugging server:eosdebuggerOn Windows, use a Docker image to run a debugging server.First, pull ipyeos docker image:dockerpullghcr.io/uuosio/ipyeos:latestthen start a debugging server from docker:dockerrun-it--rm-p9090:9090-p9092:9092-tghcr.io/uuosio/ipyeosHere's a sneak peek of the debugger in action:Code Coverage AnalysisTo generate a code coverage report in HTML, follow these steps:Build your project:go-contractbuildGenerate a coverage report:TEST_COVERAGE=1gotest-coverprofile=coverage.outCreate an HTML report from the coverage data:gotoolcover-html=coverage.outHere's an example of what the code coverage report looks like: