Vote by smart contract
Cast your vote directly on chain by calling smart contracts public function
Last updated
Cast your vote directly on chain by calling smart contracts public function
All published polls would have a clarity smart contract to capture the votes and more details on the chain.
All deployed smart contracts will have a "cast-my-vote" public function, which accepts the following parameters.
It is a required field. The data type is a "list of string ASCII" with a limit of 36 characters.
(vote (list 2 (string-ascii 36)))All selected option ids should be passed here. Option ids are available in poll JSON. The Poll JSON link is attached under the information section on the published Poll screen.
It is a required field. The data type is a "list of unsigned integers".
(volume (list 2 uint))A number of votes for each selected option. It should be in the same order as the above option ids.
It is an optional field. The data type is a "list of string ASCII" with a limit of 256 characters".
(bns (string-ascii 256))BNS name of the voter. It is required to be passed when the poll strategy is BTC Name holders. Else you can pass an empty string ASCII.
It is an optional field. The data type is a "Buffer" with a limit of 20 characters".
The domain of the BTC name. It is required to be passed when the poll strategy is BTC Name holders. Else you can pass an empty buffer.
It is an optional field. The data type is a "Buffer" with a limit of 48 characters".
The namespace of the BTC name. It is required to be passed when the poll strategy is BTC Name holders. Else you can pass an empty buffer.
It is an optional field. The data type is a "list of unsigned integers".
All NFT token holding ids need to be passed here. It is required to be passed when the strategy token type is a Non-fungible token. Else you can pass an empty list.
You can use the @stacks/transaction npm package to call clarity smart contract functions. The below-attached link has more information about the smart contract function call.
Last updated
(domain (buff 20))(domain (buff 48))(token-ids (list 60000 uint));; Cast your vote
(define-public
(cast-my-vote
(vote (list 2 (string-ascii 36)))
(volume (list 2 uint))
(bns (string-ascii 256))
(domain (buff 20))
(namespace (buff 48))
(token-ids (list 60000 uint))
)
;; Body of the function
)