flow-go-sdk
flow-go-sdk copied to clipboard
I can not generate address, please help me
gen := flow.NewAddressGenerator(flow.Mainnet)
address := gen.Address()
fmt.Println(address.Hex())
fmt.Println(address.String())
When I want to generate flow address, it panic : windows:
# github.com/onflow/atree
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\typeinfo.go:33:15: undefined: cbor.StreamEncoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\typeinfo.go:39:16: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\encode.go:31:26: undefined: cbor.StreamEncoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\encode.go:61:16: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\array.go:273:34: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\array.go:605:12: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:454:32: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:535:39: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:588:45: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:798:52: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:798:52: too many errors (exit status 1)
mac os:
# github.com/onflow/atree
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/typeinfo.go:33:15: undefined: cbor.StreamEncoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/typeinfo.go:39:16: undefined: cbor.StreamDecoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/encode.go:31:26: undefined: cbor.StreamEncoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/encode.go:61:16: undefined: cbor.StreamDecoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/array.go:273:34: undefined: cbor.StreamDecoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/array.go:605:12: undefined: cbor.StreamDecoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/map.go:454:32: undefined: cbor.StreamDecoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/map.go:535:39: undefined: cbor.StreamDecoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/map.go:588:45: undefined: cbor.StreamDecoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/map.go:798:52: undefined: cbor.StreamDecoder
../../../Workspace/Environment/gopath/pkg/mod/github.com/onflow/[email protected]/map.go:798:52: too many errors (exit status 1)
this sounds like a versioning issue in go.mod
can you post your full project with go.mod so I can debug?
@nvdtf Thank you very much, I have resolved it
I still can not create account via examples in this repo: I have created an account via Flow Wallet, then I wan to create an account via Golang Program, But it failed with error:
panic: get transaction ID ec009a44151b0b0191475b49b74181d865669804166da84927d11212e51df755 failed: Flow resource not found: no known transaction with ID ec009a44151b0b0191475b49b74181d865669804166da84927d11212e51df755 [recovered]
panic: get transaction ID ec009a44151b0b0191475b49b74181d865669804166da84927d11212e51df755 failed: Flow resource not found: no known transaction with ID ec009a44151b0b0191475b49b74181d865669804166da84927d11212e51df755
I debug my program , it panic from the code on this line:
accountCreationTxRes := examples.WaitForSeal(ctx, flowClient, createAccountTx.ID())
I have replace my address and key in the json file:
my address is : ad25383c17a21ef7
I have upload my code below, please check
The Go SDK examples connect to the Emulator, so they use a local signer:
serviceAcctAddr, serviceAcctKey, serviceSigner := examples.ServiceAccount(flowClient)
You updated the example to connect to Mainnet, so you need an actual mainnet account with a private key. You can't use the emulator service account on Mainnet.
I have indeed replaced it with the address and private key of the main network. In the file I uploaded above, the address and private key of the main network were exported from Flow Wallet, including the AccountKey information of the account.
It looks like the transaction sent was successful https://www.flowdiver.io/tx/ec009a44151b0b0191475b49b74181d865669804166da84927d11212e51df755.
I have a feeling this just has to do with an incorrect WaitForSeal implementation in the example. The transaction may not exist yet right after it has been submitted. This implementation does not account for this factor and may prematurely error.
https://github.com/onflow/flow-go-sdk/blob/9424cdb9ed2c5ebcf9144c92ef98d1ba90fff2d0/examples/examples.go#L289-L305
@jribbink Thank you, I have already created a Flow Account for a new project, but I cannot migrate my code to the existing project.
I have uploaded my code in a zip file below, along with the go.mod file. My project name is kerying_learn below ,Please help check where the incompatibility might be.
The code for create the Flow account is in the flow_test.go file under the address package, and the method is Test_Make_Flow_Address. You can run debug test to reproduce my error.
Error info:
Starting: C:\Users\Administrator\go\bin\dlv.exe dap --listen=127.0.0.1:59644 from d:\kerying_all\dev_keyring_gitee\kerying_learn\address
DAP server listening at: 127.0.0.1:59644
Build Error: go test -c -o d:\kerying_all\dev_keyring_gitee\kerying_learn\address\__debug_bin988134674.exe -gcflags all=-N -l .
# github.com/onflow/atree
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\typeinfo.go:33:15: undefined: cbor.StreamEncoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\typeinfo.go:39:16: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\encode.go:31:26: undefined: cbor.StreamEncoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\encode.go:61:16: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\array.go:273:34: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\array.go:605:12: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:454:32: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:535:39: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:588:45: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:798:52: undefined: cbor.StreamDecoder
C:\Users\Administrator\go\pkg\mod\github.com\onflow\[email protected]\map.go:798:52: too many errors (exit status 1)
@godlovericea
From Discord: ( from @SupunS )
it seems like the project has multiple cbor versions (through transitive dependencies), and picks the wrong version. i.e: atree
v0.8.1needs cborv2.4.*, but for some reason its pickingv2.5.*it's coming fromgithub.com/everFinance/[email protected] --> github.com/everFinance/[email protected] --> github.com/fxamacker/cbor/[email protected]Ifgithub.com/everFinance/arseedingis a library they own, they may have to downgrade the cbor version tov2.4.*there, and use that
@bluesign Thank you, I want make a new project for Flow