Go SDK : account balance zero even if the dispenser sent 1,300 Algos

Hi all !
I’m a newby and i’m trying to develop my first app by Go SDK for sending transactions in Testnet. In the following call :

sendResponse, err := algodClient.SendRawTransaction(signResponse.SignedTransaction)

I always recevive an error message like this:

HTTP 400 Bad Request: TransactionPool.Remember: transaction MGAPXY76P3PSTBFSVKI5YJ7F4F74UJ3CRXH6AIT6XWGOC6GP237Q: overspend (account F6P5WOQV7FDTJVC4SD54HLLESAVJFXT63KW23BG5BSKTUSKAKF22DEAGBU, data {_struct:{} Status:Offline MicroAlgos:{Raw:0} RewardsBase:0 RewardedMicroAlgos:{Raw:0} VoteID:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] SelectionID:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] VoteFirstValid:0 VoteLastValid:0 VoteKeyDilution:0 AssetParams:map Assets:map AuthAddr:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ AppLocalStates:map AppParams:map TotalAppSchema:{_struct:{} NumUint:0 NumByteSlice:0}}, tried to spend {1000})

Seeing the word “overspend” in the error message I checked the sender account balance.
Checking it by:

https://testnet.algoexplorer.io/address/F6P5WOQV7FDTJVC4SD54HLLESAVJFXT63KW23BG5BSKTUSKAKF22DEAGBU

I see 1,300 Algos (given by the “dispenser”)

But checking by the Go app with this statement:

accountInfo, err := algodClient.AccountInformation(fromAddr)
fmt.Printf(“Account balance : %d microAlgos\n”, accountInfo.Amount)

I see 0 algos.

Is this zero balance into the Go app the cause of failure in sending the transaction?
If so, why it is zero if the “algoexplorer” shows 1,300 Algos?

Any help?
Thanks.

Are you sure your algodClient is connected to TestNet?
Can you provide the code you used to instantiate algodClient?

Also to add on to what @fabrice asked, if you have a local node you are using and it isn’t caught up to the ledger block height yet, the balance won’t be available locally.

Here is the initial part of the Go application:

Here is the node status:

The last block in TestNet is 11537260, your local node isn’t yet aware that you have a balance available and won’t until it processes the block where the tokens were sent.

I would recommend using either the Docker sandbox project, or an API hosted by a 3rd party, or try-out fast catchup on the local node as a full sync can take days.

To complement Tim’s answer: If your node is not archival, you can use fast catchup which should take one hour or so. See Algorand Developer Docs

Note that fast catchup does not work with archival nodes and that archival nodes are required to use Indexer v2.

I forced a fast catchup by:

goal node catchup 11530000#GLB3YIGHPPZENJ3T7W5JS2PX75PB7EICOEN6N7CCJIQ7TUKMQ4HA

Here the node status while catching:

fast-catchup-1

Here the node status now:

It seems to me that nothing happened. since the last committed block is again around 49### instead of 11530###.

Did I make mistakes?

Which version of goal are you using?
goal version -v

If it is not 2.3.0, please update and try again.

Otherwise, you may have some issues with your Internet connectivity to relays and may need to try the solution proposed there: Fast Catchup not working for our node on MainNet - #4 by tsachi

Here the goal version:

ubuntu@em-blockchain:~$ goal version -v
Version: [v1 v2] 
GenesisID: testnet-v1.0 
Build: 2.3.0.stable [rel/stable] (commit #07bc97b7)

Please, remind that I’m using algorand on a remote virtual machine (i.e. Openstack with Ubuntu 18.04, located in office) ; there the normal catchup is very, very slow and the fast catchup doesn’work at all, probably caused by the virtualization or by the Internet connectivity.

So, to verify this hypothesis, I just installed algorand on a physical machine (laptop with Ubuntu 18.04, in a different location and with a completely different Internet connection); here the normal catchup is really faster and the fast catchup works very well (few minutes to reach the top of the chain).

I will check with colleagues the Openstack virtualization and the Internet connection.

Thanks a lot for your help.

@i4gipi On your client instantiation, I noticed you are using V1. Try this import statement instead for V2 for algod.

"github.com/algorand/go-algorand-sdk/client/v2/algod"

and this is the code to get the account info:

	// Check account balance
	accountInfo, err := algodClient.AccountInformation(myAddress.String()).Do(context.Background())
	if err != nil {
		fmt.Printf("Error getting account info: %s\n", err)
		return
	}

And here is a complete example I have just finished with V2 client, waitForConfirmation, pay transaction, account info and read//write note field that may be of interest. https://github.com/algorand-devrel/hackathon/blob/master/algorandsamples/v2/mygodemo/src/firsttransaction/noteField.go

@rfustino

Thanks for your help. Now I’m working on a physical machine instead of a virtual one and everything works fine: my node is up-to-date by fast catchup and my Go app creates and publishes a signed transaction with JSON metadata in the ‘note’ filed. I check the results into the blockchain by https://testnet.algoexplorer.io and everything is OK.

Thanks a lot for your complete example with a V2 client; I’ll see and use it.

My next step will be understanding how to write Smart Contracts by TEAL.