Questions tagged [clarity-lang]

Use in relation to the Clarity smart contract language (part of the Stacks blockchain platform).

Clarity is a language that brings smart contracts to .

It's documentation can be found on the Clarity web page.

Used with the Stacks blockchain.

24 questions
2
votes
2 answers

How to get a particular value from a map

In my contract I have a map with a principal as its key and a tuple as its value. I want to get a particular value from the value-tuple for every principal in the map. Let's say I want to get the salary for every member from the map…
1
vote
1 answer

Public function smart contract Clarity Stacks

I am writing a public function that only owner of the contract can call. It is a funciton that changes a state variable in a smart conract. (define-public (changeRatio (newRatio uint)) (begin (asserts! (is-eq tx-sender (var-get…
Brian
  • 11
  • 1
1
vote
1 answer

Clarity conversion string to uint

I want to concatenate a string with an uint. Found the best method is to have two strings and concatenate them. How can any uint be converted to a string?
Deployer
  • 13
  • 2
1
vote
0 answers

How to set up an environment to write/test Clarity smart contracts within a Django project

I'm setting up a web project that can (i) interact with the Stacks blockchain and (ii) deploy/interact with Clarity smart contracts. I need help in configuring the environment correctly. Following is how I typically setup web projects. I typically…
Hassan Baig
  • 15,055
  • 27
  • 102
  • 205
1
vote
1 answer

How to join two utf8 strings together in Clarity?

In my Clarity smart contract, I am trying to to append one string ("Hello") to another string (" to Clarity Language"). Both strings are of type string-utf8. Deploying the contract below fails with an error: expecting expression of type…
0
votes
1 answer

Unit Test Clarity Language

I have a question on about Unit Test While I putting some code on Tx.contractCall in the .ts file, what types should I choose if I want to put contract name? Tx.contractCall( ""dex"", ""provide-liquidity"", …
0
votes
1 answer

Fold or map function & pass in list as parameter Clarity Smart contracts

I have a question regarding the fold or map function and how they can be used. This, as well as passing in a list. how can the fold or map function be used to run another function more then once? How can i pass in a list as a parameter to a…
0
votes
1 answer

Question regarding this notice in Clarity extension

Question regarding this notice in Clarity extension v0.7.1 (define-public (lock (new-beneficiary principal) (unlock-at uint) (amount uint)) Returns: 'source of untrusted input here' (var-set beneficiary (some new-beneficiary)) Returns: 'use of…
0
votes
1 answer

Print current value of missing variables during manual testing - Clarity Smart Contract

Is it possible to print the current value of variables during manual testing to see how they are behaving? I mean during manual testing in the clarinet console or do I have to add something like (ok variable_name) at the end of the function?
0
votes
1 answer

Clarity Smart contract function loop if error

can someone help me understand why my 'get-employee-2nd...' function seems to loop if the check index u1 and returns (ok none) for other indexes. (define-public (get-employee-2nd-club- name-from-tuple) (let ( …
0
votes
1 answer

Where can I find a list of all operations possible on lists and maps for Clarity Smart Contracts?

Is there a resource for Clarity Smart contracts on Stacks that contains all operations possible on lists and maps? for instance for lists, I see in the book that you can append but can you also remove elements? I am not sure whether this is also…
0
votes
1 answer

Clarity Smart contract validate principal calling public function

When writing a Clarity Smart contract, how can you validate the principal that is calling into a public function. I don't know where to find the answer to this question.
0
votes
1 answer

Define Non Fungible Token - Stacks Clarity Smart Contract

Question, the two functions "define-non-fungible-token" and "define-trait" are unrelated... right? The function "define-non-fungible-token" is used to create an NFT. While the function "define-trait" is used so that another contract can utilize that…
0
votes
1 answer

Define functions expression - Clarity Smart contract Stacks

The expressions that define functions take one expression for the function body. [The function body is what is executed when the function is called.] If the body is limited to one expression only, then how can you create more complex functions that…
0
votes
1 answer

Running Clarity Smart Contracts u0 u1 u2 function

If I run the following: (define-data-var even-values uint u0) (define-public (count-even (number uint)) (begin ;; increment the "event-values" variable by one. (var-set even-values (+ (var-get even-values) u1)) ;; check if the input…
1
2