Skip to the content.

Godence

codecov Unit Test Go Reference GitHub top language

Get Started

install by go get.

go get github.com/lemonnekogh/godence

Convert Cadence value to Go value

If you have the following Cadence struct.

pub struct Person {
    pub var age: UInt8
    pub var Name: String
}
import "github.com/LemonNekoGH/godence"

type Person struct {
    Age uint8 `godence:"age"` // you can specify field name in cadence by tag.
    Name string
}

func main() {
    dist := &Person{}
    // Omit: You got a Cadence value from a script or transaction. And return value named 'ret'.
    godence.ToGo(ret, dist)
}

Convert Go value to Cadence value

Convert to Cadecne Struct, Event, Resource is currently not support becase type name of Struct, Event, Resource is unpredictable.
Can i convert to AnyStruct and AnyResource?

Testing

Requirements

Steps

  1. Start the flow emulator with command: flow emulator
  2. Deploy contract for testing to the emulator network: flow deploy
  3. Open another terminal and run go clean -testcache && go test .

TODO-List: Go to Cadence

TODO-List: Cadence to go