Hi all… very excited about the USDC announcement and post from @andrea and I’m trying to start leveraging it.
It seemed like the simplest thing to start with would be to follow the setup instructions and then simply try to get a balance but I’m getting an error.
I have a Circle sandbox wallet setup with a Flow, have successfully funded the account via faucet. Also have updated my dev environment to latest @onflow/fcl and flow-cli just to be sure.
Any help would greatly appreciated!
Here’s the script - the code is identical to the get_balance.cdc in the flow-usdc Github (flow-usdc / scripts / vault / get_balance.cdc)
import {send, decode, script, args, arg, cdc} from "@onflow/fcl"
import {Address} from "@onflow/types"
const CODE = cdc`
import FungibleToken from 0xFungibleToken
import FiatToken from 0xFiatToken
pub fun main(account: Address): UFix64 {
let acct = getAccount(account)
let vaultRef = acct.getCapability(FiatToken.VaultBalancePubPath)
.borrow<&FiatToken.Vault{FungibleToken.Balance}>()
?? panic("Could not borrow Balance reference to the Vault")
return vaultRef.balance
}
`
export function fetchUSDCBalance(address) {
if (address == null) return Promise.resolve(0)
// prettier-ignore
return send([
script(CODE),
args([
arg(address, Address)
])
]).then(decode)
}
Browser stack trace is as follows:
send-execute-script.js:49 Uncaught SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at o (send-execute-script.js:49:1)
|o|@|send-execute-script.js:49|
|---|---|---|
|Promise.catch (async)|||
|putIntoCache|@|recoil.js:4426|
|getFromCacheOrEvaluate|@|recoil.js:4484|
|(anonymous)|@|recoil.js:4615|
|detectCircularDependencies|@|recoil.js:4570|
|myGet|@|recoil.js:4615|
|getNodeLoadable|@|recoil.js:424|
|getRecoilValue|@|recoil.js:4498|
|evaluateSelectorFunction|@|recoil.js:4516|
|getFromCacheOrEvaluate|@|recoil.js:4478|
|(anonymous)|@|recoil.js:4615|
|detectCircularDependencies|@|recoil.js:4570|
|myGet|@|recoil.js:4615|
|getNodeLoadable|@|recoil.js:424|
|getRecoilValueAsLoadable|@|recoil.js:690|
|useRecoilValueLoadable_LEGACY|@|recoil.js:2519|
|useRecoilValueLoadable|@|recoil.js:2533|
|useRecoilValue|@|recoil.js:2551|
|useRecoilState|@|recoil.js:2603|