Questions tagged [smart-contracts]
The smart-contracts tag has no usage guidance.
407
questions
1
vote
1
answer
18
views
How to make a call of struct in smartPy
I need to make the following struct call in smartPy.
Types.TransferCoin(_strFrom, _toAddress, _assets)
The Types.sol files has the following struct:
struct TransferCoin {
string from;
...
0
votes
1
answer
20
views
SmartPy, File "smartML/tools/compiler.ml", line 2210, characters 18-24: Assertion failed
I am creating a big_maps with a value type of struct Assets and AssetsDetails. While i try to put the value in map getting an error of: [error] File "smartML/tools/compiler.ml", line 2210, ...
4
votes
3
answers
177
views
What's wrong with my calculation of fees and burn here?
I am trying to calculate the cost of a transaction, post-hoc, from the response to calling the entrypoint. This is for the purposes of a testing tool I am building that I need accurate costs for.
As ...
2
votes
3
answers
56
views
HttpRequestFailed with taq originate counter.tz from quickstart
I apologise in advance if the question I am trying to ask is trivial and not very interesting.
I have just started to get interested in the tezos blockchain and its tools and I am encountering an ...
0
votes
0
answers
38
views
Is it possible to have an entrypoint call return the gas expended in Archetype mockup mode?
I am writing some basic tests and I want to confirm that the balances of various accounts are correct after an entrypoint is called. I would like to ensure fees have been properly accounted for so my ...
0
votes
2
answers
63
views
Using Pytezos to Properly call a smart contract with correct parameters ( to purchase token from objkt )
I am hitting a wall trying to figure out a working proof of concept to get pytezos to "purchase" a token from objkt. I am using the following script with pytezos under the assumption that:
...
1
vote
1
answer
43
views
How do we achieve a variable type of struct in smartPy
I am translating following code in solidity to smartpy. How do we achieve a variable type of struct in smartPy.
Types.AssetTransferDetail[]
memory _assetDetails = new Types....
0
votes
1
answer
8
views
How can I apply a minus operation to Tez type in the archetype testing library?
I am writing some simple contract tests, and I want to check that account balances are updating appropriately.
There is currently no minus method on the Tez type. I attempted to add my own to the ...
2
votes
1
answer
56
views
archetype: how to remove the bytes that are prepended by the pack() routine
I am trying to concatenate two strings and then convert to bytes using pack(). However this prepends some bytes to the front of the result.
var str1 : string = "TEST INDEX #";
var str2 = ...
1
vote
1
answer
26
views
Do partitions reduce gas usage?
I have a ledger asset which is a big map.
Each entry has a partition leading to another other asset, which in the worst case will have 20 entries in it associated with one entry in the ledger asset (I'...
0
votes
1
answer
46
views
Got this error during ghostnet deployment, "No case matched: At /kind, unexpected string instead of endorsement"
I tried to originate a smart contract using smartpy ide and this is the error what I am getting.
An update on this
I tried commenting all the sp.emit() in the code and deployed. Then it was working ...
0
votes
1
answer
48
views
How can I check if an address is a contract vs account (or how can I convert an address to a string) in archetype?
I am attempting to write a simple function to check if an address is an account (e.g tz1, tz2 etc) or contract address (KT).
I want to write something like this:
function isAddressContract(ad: address)...
3
votes
1
answer
61
views
Can you update the storage of an external contract and retrieve the updated storage item via on-chain view in the same contract call?
I am exploring an FA2 implementation where the storage and the business logic are in different smart contracts (a pattern for upgradability)
This case could see instance of both updating the item in ...
0
votes
2
answers
25
views
How can I assign values for a map-type in an archetype test script?
I have the following typescript in my test script:
const tmdBytes = Bytes.hex_encode("ipfs://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
const tmdMap : Array<[ ...
0
votes
2
answers
31
views
NatValidationError when deploying an archetype contract with taquito
I am attempting to deploy a very simple archetype contract with Taquito in a react Dapp. However, I am receiving a validation error. My guess is that I have the syntax wrong for the storage parameter, ...
0
votes
1
answer
28
views
How do you originate an archetype contract from within a dapp?
I’m trying to figure out how to originate a new contract from within a dapp. I seem to have found what I am looking for here: https://tezostaquito.io/docs/originate
Here is the example code I am ...
2
votes
1
answer
93
views
Extracting entropy from bytes
most smart contracts that rely on "randomness", will require said entropy to be in a number format. A practical way to extract entropy from a arbitrary payload is by using a hashing function....
-1
votes
1
answer
67
views
calling onchain view through other contract
I am facing a weird issue on smartpy.
This is the onchain view added on fa2Fungible contract.
@sp.onchain_view()
def check_operator(self, params):
sp.set_type(params, sp.TRecord(owner=sp....
0
votes
1
answer
41
views
How to call an entrypoint from the current contract?
There is a straightforward example of how to do this in the docs, however it does not seem to work for me. With the following code which I basically copied straight from the docs ...
entry ...
2
votes
1
answer
73
views
How can I convert duration to int or nat in archetype?
Or: How can I multiply duration and tez? (I need tez as my output)
I would usually write something about what I have tried - but I don't really know where to start with this one. I have looked through ...
3
votes
1
answer
79
views
Securely moving from Ghostnet to Mainnet
Are there any important things to do or check before moving a dApp from Ghostnet to Mainnet?
0
votes
1
answer
79
views
Vanity address generator for contracts
Is that even possible for Tezos contracts?
There is a vanity address "generator" in JS for tezos.
See github
So looking for something like this but for Tezos contracts.
1
vote
1
answer
19
views
Is there an equivelant of javascript template literals in archetype?
Is it possible to include the value of variables in error messages?
For example I would like to do something like this Javascript / Archetype hybrid:
do_require(feeOne + feeTwo = feeTotal, `Fees do ...
1
vote
1
answer
31
views
How to extract content of an archetype option, but fail if content is `none`?
I have tried this:
entry makeOffer() {
require {
r_higherBid: topBid ? transferred > the : false otherwise "your Bid must be higher than current topBid";
} effect {
match ...
0
votes
1
answer
38
views
Details on VDF for randomization
so i was going through this article,
https://research-development.nomadic-labs.com/verifiable-delay-functions.html
the more i read it, the more i got confused, Is there a easy way we can achieve this ...
1
vote
1
answer
172
views
Archetype Error: types have seperate declarations of a private property '_content'
I am receiving the following error from vscode even with the most minimal contract and tests in a fresh completium-cli project:
Argument of type 'import(\"/Users/grum/royaltiesProject/rrtwo/...
0
votes
1
answer
80
views
Using dummy address for randomization
Hey below function is used to originate a dummy contract address.
As tezos doesn't provide transaction hash or block hash.
I am planning to use dummy contract address as a seed and then generate a ...
1
vote
1
answer
47
views
How can I perform operations on smartpy sp.TBytes?
I'm currently trying to perform on-chain image mutation. I'm writing the smart contract using smartpy.
The idea is:
The image is on-chain "Raw PPM encoded", in sp.TBytes format. Each pixel ...
1
vote
1
answer
42
views
General Information
I know tezos strongly believes in immutability but I would like to clear out some curiosity regarding upgradability of a contract.
If a function in a contract needs to be updated with it's logic , ...
2
votes
1
answer
85
views
How to get randomness for my game?
Let's say a player encounters an enemy on a grid-based game, how can I generate a random number on chain to generate the enemy basic characteristics ( HP, strength, agility... ) at the time of the ...
0
votes
1
answer
28
views
Let bakers pass their own entropy to generate random numbers on chain
Might be a stupid question, but would it be possible to let each bakers emmit a random number each time a block is baked, then aggregate those numbers, make a hash from the result, and store it in the ...
0
votes
1
answer
38
views
Translate SmartPy expression into Michelson
import smartpy as sp
def logic(data):
t = sp.TRecord(x=sp.TNat, y=sp.TNat, z=sp.TNat)
unpacked = sp.unpack(data, t).open_some(message="Can't unpack!!")
sp.result(unpacked.x ...
0
votes
1
answer
25
views
interact with FA2.0 Smart Contract
I deployed a FA2.0 Smart Contract and would need to interact with it through Java. I tried to use Tezosj (enter link description here) but it does not support FA2.0 smart contracts...hence, I would ...
1
vote
1
answer
30
views
What is the taquito way of building a lambda?
So, this is the piece of code in my smartpy test contracts. Both methods, calc_reward and updateLogic is working. This is in the test section of the contract.
So, basically, what I want to do is call ...
0
votes
1
answer
41
views
Updating Smart Contracts
I am new in tezos and I am trying to find a way to upgrade my smart contract. I found out we will be able to upgrade a contract using proxy delegate contract or storing lambdas on the contract.
...
1
vote
0
answers
43
views
How does an oracle contract get data from outside the blockchain?
I want to build an oracle which gets data on chain from a weather API.
The way I'm thinking about implementing this is to run a server which periodically fetches the data from a weather API, and calls ...
1
vote
0
answers
23
views
Counter for wallet is not incremented after mint using taquito
I'm minting successfully from a contract. Then when I go to transfer the NFT I get the error: "HttpResponse: Http error response: (500) [{"kind":"branch","id":"...
0
votes
1
answer
22
views
Please help me to get archetype language support in vscode working
I am unable to get archetype language support working on vscode
I recieve the following error under the problems tab:
Error (parsing)
Error while analyzing archetype or archetype or archetype
or ...
2
votes
2
answers
159
views
Random number on-chain
Since all the answers are a bit old, is there a better or more generic way to get a random number on-chain than using Harbinger Oracle? Would it be safe to imagine a community approved & audited ...
0
votes
0
answers
45
views
Not enough gas for initial manager cost
Unrecognized error: proto.alpha.validate_operation.insufficient_gas_for_manager
I have been seeing this error out of nowhere anyone have any clue ? i am using kukai wallet ithacanet.kukai.com and my ...
0
votes
0
answers
43
views
Call smart contract in game in a decentralized way
Let's say I want to create a shooter game, and a smart contract increments each time a player manages to shoot a target.
Is there a way to call this smart contract in a decentralized way, using an ...
1
vote
1
answer
56
views
Is there a Michelson to Archetype (or other higher-level language) transcompiler/decompiler?
Given an arbitrary smart contract address or Michelson code, for example:
parameter (or
(contract %push (big_map string
(pair timestamp
...
1
vote
1
answer
92
views
about royalty of Tezos NFT
I want to know about the royalties of Tezos NFT. how can I collect the royalty. what are the restriction on the Tezos side. how to write the smart contract with including royalty and are there any ...
0
votes
0
answers
27
views
"Cannot unify set with unit" error
I am trying to write a simple contract in which I am using set of records as storage.
type data = {
message : string,
did: address
};
type parameter =
| ["Published"]
| ["...
3
votes
3
answers
133
views
Smart contract availability and diversity on Tezos
I am researching about Tezos to what smart contract language there are available to use. When I look at the TezosWiki and other sources I came up to with this list:
Tezos Smart Contract Languages:
...
0
votes
1
answer
72
views
Liquidity Baking interactions from a DAPP - Error during estimation being returned from temple wallet
I'm working on building an interface for liquidity baking and am encountering the error: Error during estimation when I submit the calculations for the swap tokenToXtz or xtzToToken on the swap ...
0
votes
2
answers
48
views
TransferOwnership in Tezos
Is there an analog of transferOwnership in Tezos?
It looks like it's possible to make custom FA2 contract and change owner. Is this correct?
Looking for an authorative answer
2
votes
2
answers
86
views
/run_script_view gives "RpcException: HTTP/1.1 404 Not Found" on ghostnet
So I am trying to run a view operation with a post method on ghostnet:
https://rpc.ghostnet.teztnets.xyz/chains/main/blocks/head/helpers/scripts/run_script_view/
with this data:
{“contract”:“...
1
vote
1
answer
56
views
Tezos Smart Contract Language Specifications
Is there an equivalent "interface" keyword in any of the Tezos smart contract languages (i.e. smartpy, archetype, ligo) that is similar to solidity's keyword "interface".
If there ...
0
votes
1
answer
48
views
What are the differences between the chain view decorators in SmartPy?
Considering the following SmartPy decorators:
@sp.utils.view
@sp.onchain_view
@sp.offchain_view
What are the differences in use between them?