Questions tagged [onflow-cadence]

Cadence is a smart contract language primarily for the Flow blockchain. Use this tag for questions about programming smart contracts using the Cadence language.

Cadence is a resource-oriented programming language that introduces new features to smart contract programming that help developers ensure that their code is safe, secure, clear, and approachable.

57 questions
0
votes
1 answer

In Cadence, the functions returned values that include an interface are checking for conformances or restricting the type?

Let say I have a function that goes something like... pub fun myFunction(): &{FungibleToken.Receiver} If myFunction() returns for instance a &ExampleToken.Vault (a reference to a resource, a fungible token vault, that conforms to…
alilloig
  • 456
  • 1
  • 4
  • 11
0
votes
1 answer

How to compare two instances of the same struct in Cadence?

I'd like to compare two instances of the same struct to see if their fields have all the same value. I believe that according to the docs the equality operator wont't work on structs. What would be the right approach here? Writing a custom equals…
alilloig
  • 456
  • 1
  • 4
  • 11
0
votes
1 answer

Does ever calling `check()` on a capability panic?

According to the docs there is no reference of check panicking in any situation, but I would like to know if there is any edge case where this method could panic rather than returning false.
alilloig
  • 456
  • 1
  • 4
  • 11
0
votes
1 answer

How do I get a collection id for flow blockchain nft project?

I'm trying to get information about an NFT collection on the Flow blockchain using this in api docs - https://developers.flow.com/http-api#tag/Collections/paths/~1collections~1%7Bid%7D/get I have no idea where to get the {id} it asks for. The…
user100911
  • 15
  • 5
0
votes
1 answer

Pass a copy of an object in storage without the reference to avoid users from modifying the object in storage

pub fun getAddresses(): {Address: Bool} { return Contract.account.borrow<&{Address: Bool}>(from: storage/dict) as! {Address: Bool} } In other words, I don’t want to pass back to the caller the reference to the dictionary because then they…
pho_pho
  • 672
  • 11
  • 30
0
votes
1 answer

How to import contracts in Cadence using flow.json instead of relative paths

Importing contracts using their relative path is not working atm with the last version of the cadence language server. I was wondering what would be the alternative, when developing locally, for importing other contracts. My best guess is that it…
alilloig
  • 456
  • 1
  • 4
  • 11
0
votes
1 answer

Does updating/redeploying a smart contract on Flow reset its state on mainnet?

Following this official guide here https://developers.flow.com/flow/dapp-development/mainnet-deployment#updatere-deploy-a-contract-on-mainnet-using-the-cli I would like to make some updates to a smart contract I've got on Mainnet and there's a bunch…
Aylii
  • 525
  • 4
  • 10
0
votes
1 answer

Is there really still no way of converting a string to an integer in Cadence?

Seems like such a basic thing. A similar question was posted 9 months back in the Cadence discord and the answer was no - just checking that is still the case. I'm trying to pass a serial number encoded as a string in the NFT metadata as an argument…
N8P
  • 393
  • 1
  • 4
  • 11
0
votes
1 answer

I have deployed a smart contract Onflow in testnet, how to update or delete them?

Hi, I have deployed a smart contract in testnet, how to update or delete them? i tried both https://flow-view-source.com/ and CLI but both get this error
0
votes
1 answer

When querying Flow blockchain I get a CORS error

When executing a query through javascript I get a CORS error: Access to fetch at 'http://access.mainnet.nodes.onflow.org:9000/v1/scripts?block_height=sealed' from origin 'http://localhost:3000' has been blocked by CORS policy: No…
user1596863
  • 116
  • 3
0
votes
1 answer

How to get transaction fees when testing using flow-js-testing

I have a mint tx that is paid which I am testing, and i expect this to be true: usersBalanceAfterMinting == usersBalanceBeforeMinting - costOfMinting - txFee However, when i print out the events from the tx, there is no feesDeducted event, and no…
pho_pho
  • 672
  • 11
  • 30
0
votes
1 answer

migrate Flow NFT Execution Failure

i have many problem with my flow wallet (blocto), same error on flowscan...for migrate my NFT's from RaceDay to Dapper. Idea? transaction: a7892853f4fa8430f9095cefb8031e58055e6599a2a8ea79a22fb2312fedfa18 Execution Failure [Error Code: 1110]…
0
votes
2 answers

Integrating Flow Blockchain in Flutter

I am trying to develop a dAPP using the Flow Blockchain in Flutter. I cannot find any library or package that I can use to do so. Is this even possible in Flutter?
mr.SoSerious
  • 121
  • 1
  • 9
0
votes
1 answer

Flow Emulator with Initial Accounts

I'm trying to initialize the flow emulator with accounts. Here's my flow config file: { "emulators": { "default": { "port": 3569, "serviceAccount": "delphai" } }, "contracts": { …
codhur_jones
  • 153
  • 9
0
votes
2 answers

How to pass in `Type` to transactions and scripts in Flow CLI

Given a script: pub fun main(type: Type): Type { return type } How do you pass in a Type param to the script using Flow CLI? Using this command: flow scripts execute ./cadence/scripts/test.cdc --args-json…
pho_pho
  • 672
  • 11
  • 30