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
11
votes
11 answers

curl: (28) Failed to connect to raw.githubusercontent.com port 443: Connection timed out

I am facing one error while installing FCL-CLI on my system (linux). The command I have used is: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" Error: curl: (28) Failed to connect to…
Mod Ranjan
  • 111
  • 1
  • 1
  • 5
3
votes
2 answers

How can I listen to an event from my smart contract on Flow blockchain?

I used some services for listening to an event from my smart contract on Ethereum. But I can't find any documents similar to that when working with Flow Blockchain. How can I do that?
2
votes
1 answer

What is the idiomatic way to represent restrictions on the transfer of NonFungible resources on Flow?

There are a large number of things that are NonFungible but have their own unique restrictions. Let's take a specific example for discussion, a physical car. Let's assume ownership of that car is associated with a NonFungibleToken. Also, let's focus…
Jamil R Khan
  • 386
  • 1
  • 9
2
votes
1 answer

Is it possible to iterate over dictionary keys?

The current method of accessing dictionary keys is through the use of the .keys field. However, this may result in resource exhaustion for large dictionaries. How can I iterate over the keys for the dictionary, instead of all the…
2
votes
2 answers

Do attachments have the same storage and transaction cost rules as resources themselves?

We are implementing a field that may sometimes get big in specific admin-controlled occasions and are evaluating using the new Cadence attachments feature to define that field vs having the field on the resource itself. Do attachements have the same…
Loïc
  • 41
  • 2
1
vote
1 answer

Retrieve user's current delegation and rewards in Flow programmatically using user_id

I am wondering how can I get the current delegation and rewards of a particular user by passing its user_id programatically in flow (mostly in typescript or python) !? I have tried it js SDK. but their isnt any support in it for staking and reward…
1
vote
1 answer

Does gas cost depend on the overall size of a resource that's moved/for which we access fields or only on the size of the fields actually accessed?

We are evaluating the scalability of a resource's field that might get big occasionally and would like to confirm how transaction cost is calculated in order to make sure we can continue to execute transactions that interact with that resource (but…
Loïc
  • 41
  • 2
1
vote
1 answer

Can't find a way to write a transaction to add items in my Grocery resource

I've a resource inside a resource and I've added a function to create a collection and to add items in it. I'm not quite sure how to write a transaction for it. Here's the contract and the transaction I wrote. pub contract Crash{ pub resource…
1
vote
3 answers

mismatched types. expected `NonFungibleToken.NFT`, got `NonFungibleToken.NFT?

While deploying this contract I am getting an error "mismatched types. expected NonFungibleToken.NFT, got `NonFungibleToken.NFT?".Can anyone help me why the error showing up in my code. pub contract MetaVEvents:NonFungibleToken{ pub let…
Wiswa
  • 11
  • 2
1
vote
2 answers

Unwrapping an Optional Resource in a post-condition

I am defining a function in an interface that returns an optional resource and I would like to be able to check if the return value has a certain field by unwrapping it in the post condition. Here is my code: pub resource interface Provider { …
1
vote
1 answer

Get NFT Metadata

I'm trying to get the metadata for the Genesis collection from the DriverzNFT contract this is the script I have import DriverzNFT from 0xa039bd7d55a96c0c import NonFungibleToken from 0x1d7e57aa55817448 import MetadataViews from…
RMT Books
  • 19
  • 2
1
vote
1 answer

On the Flow Blockchain what guarantees do we have on field visibility on concurrent transactions

I have been interested in thinking through a race condition in which transactions could be executed on the same block in non-deterministic order on the Flow Blockchain. Let's say you have two transactions which mutate the state of a resource by…
Jamil R Khan
  • 386
  • 1
  • 9
1
vote
1 answer

Flow Cadence: How to generate a random integer between two integer?

I tried unsafeRandom and this custom smart-contract without success: https://github.com/justjoolz/PRNG/blob/master/cadence/contracts/PRNG.cdc
ziny
  • 11
  • 2
1
vote
1 answer

Removing contract failed: [Error Code: 1056] (RemoveContract) is not authorized: removing contracts requires authorization from specific accounts

Using flow-cli, if I run flow accounts remove-contract HelloWorld --network testnet --signer testnet-account I get the above error. I created the contract using the same account but unable to remove it from testnet. I read something about using auth…
Vasu Mistry
  • 781
  • 2
  • 6
  • 18
1
vote
1 answer

field `accessory` of type `Transaction` is not invalidated (moved or destroyed). not invalidated - flow cadence

I'm developing a game and I have an avatar resource with the following definition that stores accessory NFTs and includes an equip function that returns any accessory that was existing in the slot pub resource Avatar { pub let id: UInt64 …
Aylii
  • 525
  • 4
  • 10
1
2 3 4