flow-go-sdk icon indicating copy to clipboard operation
flow-go-sdk copied to clipboard

I can not generate address, please help me

Open godlovericea opened this issue 10 months ago • 9 comments

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)

godlovericea avatar Jan 07 '25 15:01 godlovericea

this sounds like a versioning issue in go.mod

can you post your full project with go.mod so I can debug?

nvdtf avatar Jan 07 '25 21:01 nvdtf

@nvdtf Thank you very much, I have resolved it

godlovericea avatar Jan 09 '25 02:01 godlovericea

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

create_flow_account.zip

godlovericea avatar Jan 09 '25 08:01 godlovericea

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.

nvdtf avatar Jan 09 '25 20:01 nvdtf

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.

godlovericea avatar Jan 10 '25 01:01 godlovericea

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 avatar Jan 10 '25 08:01 jribbink

kerying_learn.zip

@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 avatar Jan 13 '25 08:01 godlovericea

@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.1 needs cbor v2.4.*, but for some reason its picking v2.5.* it's coming from github.com/everFinance/[email protected] --> github.com/everFinance/[email protected] --> github.com/fxamacker/cbor/[email protected] If github.com/everFinance/arseeding is a library they own, they may have to downgrade the cbor version to v2.4.* there, and use that

bluesign avatar Jan 14 '25 13:01 bluesign

@bluesign Thank you, I want make a new project for Flow

godlovericea avatar Jan 15 '25 09:01 godlovericea