Questions tagged [smart-contracts]
The smart-contracts tag has no usage guidance.
407
questions
2
votes
1
answer
118
views
Can a smart contract know its own address?
Is it possible to create a smart contract that knows the value of its KT1 address?
E.g. if you wanted the contract to check that there was a signature signed over its contract address, would it be ...
0
votes
1
answer
26
views
decidability of real world contracts
I'm wondering if there has been any work done on the decidability of real world, legal contracts.
Michelson is great because it lends itself to users bring able to write smart contracts that are ...
0
votes
1
answer
29
views
Checking total amount sent to a contract (ever) within the contract execution
I'd like to create a contract that behaves a certain way based on how much total tez has been sent to the contract.
How should I track and check the total amount ever sent to a contract?
Example:
...
1
vote
2
answers
128
views
Why is this big map update using up so many bytes?
In this question I asked why so much Tezos was burned when updating 380 cells in a grid.
It's surprising to see how many bytes it actually took though. If you look at the transaction, there were 380 ...
2
votes
1
answer
99
views
Node issues with multiple transactions to the same smart contract (FA1.2)
I was wondering if there is any explanation available to some unexpected behavior when trying to make multiple transactions to the same smart contract.
Transaction
We have an FA1.2 token whereby we ...
1
vote
1
answer
65
views
How can I encode a 2D matrix of booleans in the least amount of bytes?
I'm looking at this ethereum smart contract that iterates over an area in a 2D bool matrix to reserve pixels. When looking at a call to that ethereum smart contract for a 20x11 area, it used 0.0315 ...
1
vote
1
answer
96
views
What would be the simplest way to connect a smartpy contract to an oracle tracking the XTZ/USD pair?
I see there's a smartpy chainlink oracle example and a github repo for Harbinger. I briefly looked at the code and it appears they are for setting up Oracles + clients. Are there any existing XTZ/USD ...
2
votes
1
answer
133
views
How should a contract check whether an address owns a FA2 token created in another contract?
I've broken up my code into 2 contracts. FA2 contract and other one managing its data and providing additional functionality on top. This is to not overload a single contract, however, it does ...
2
votes
1
answer
150
views
Is there a list of public repos using smartpy?
I'd like to see more complex examples of smartpy being used in main net contracts.
So far, I've found tzcolor's auction house contract SUPER helpful. Are there any other really good examples (that are ...
1
vote
1
answer
397
views
How do offchain views work and what guarantees do they provide?
What are the technical differences between offchain views vs onchain entry points? I know one of the differences is that onchain entry points mutate while offchain views don't. Are there any other ...
1
vote
1
answer
40
views
How to migrate existing smart contract data to a new one when needing additional storage requirements?
Obviously the first answer is to try to avoid running into this scenario by having some flexibility in storing additional fields using maps (example). However, let's think about the scenario where ...
1
vote
1
answer
95
views
How to add new record fields in data storage after contract deployment? Is storing JSON in a field viable?
AFAIK, there is no way to update storage types(ex: can't add a new record field to a Map<sp.Nat, sp.record(a=1)>) of a contract after deployment. (Correct me if I'm wrong). This means, after a ...
1
vote
1
answer
32
views
Does smartpy propagate exceptions?
I'm doing something like this, but the invalid scenario assertion fails.
Is there a way to propagate the exception from the other contract? Or do I just have to test that contract separately?
class ...
1
vote
1
answer
190
views
What are good examples of upgradable smartpy contracts using Proxy delegates or stored lambdas?
I'm trying to ensure my contract is upgradable and I learn best by looking at existing examples. Does anyone have any good examples to look at?
Here are some links to previous stackoverflow Q&A's ...
1
vote
2
answers
203
views
How to fetch all the values in a big map using taquito?
Per the BigMapAbstraction Taquito API docs, there isn't a way to fetch all the values in that map.
Is the suggested way to fetch all of values in the map by doing batch queries on it then? Or what's ...
1
vote
1
answer
105
views
Incompatible parameter error when calling another smart contract
I'm getting this weird error when trying to call the mint entrypoint from another contract... I had additional parameters in the BuyLandRequest and was overriding the TezosHomepageAdNft.mint ...
3
votes
1
answer
206
views
Why aren't the offchain views appearing?
I'm extending the smartpy FA2 template
#
FA2 = sp.import_script_from_url("https://smartpy.io/dev/templates/FA2.py")
class TezosLandNft(FA2.FA2):
...
which has the following offchain views ...
0
votes
2
answers
177
views
How can I do string interpolation on smartpy?
I'm trying to provide better error messages. I've tried several things already that don't work such as regular python fstrings, regular string concatenation. I'm tried to using the sp.string function ...
0
votes
1
answer
186
views
How do I transfer tez while invoking a smart contract using Taquito?
const op = await contract.methods
.buy(contractParams?.height, contractParams?.width)
.send();
I have a buy entrypoint and would like to pass in some parameters and some tez at the ...
2
votes
1
answer
562
views
How to store and load custom FA2 NFT metadata?
First time I'm writing a smart contract. If anything doesn't make sense at all, feel free to call out what specifically doesn't make sense and suggest a better approach. Thanks!
At a high level I just ...
0
votes
1
answer
116
views
What is the one-time 0.257 tz burn fee?
I have deployed a contract on a test net and I want to send some tez to it to test out some operations. When I try to send through Temple wallet, I get:
Failed
Unable to estimate transaction to ...
0
votes
1
answer
94
views
Get entrypoint operation (get_entrypoint_opt) fails
I have some troubles to call a contract.
This is the scenario:
Contract B (Entrypoint method "transfer"):
(pair %transfer (bytes %args1)
(pair (string %args2)
...
1
vote
2
answers
141
views
Read another contract's storage without making a transaction?
Is it possible for contract X to read the storage of contract Y without making a transaction?
I think I understand how I can make X call a function on Y using a callback pattern. But since I only want ...
4
votes
1
answer
130
views
Upgradeable Contracts: Proxy Delegate vs Stored Lambdas
There are a number of design patterns for contracts that already exist on Ethereum. For upgradeable contracts, one of them is the use of a Proxy Delegate contract.
My understanding is that the Proxy ...
3
votes
1
answer
81
views
Is it possible to retrieve only a single variable from contract storage?
As far as I can tell using the taquito npm package, in order to get any storage from a contract, you have to get all of a contract's storage. This seems like it can become highly inefficient if you ...
0
votes
1
answer
58
views
Is there a way to list the supported networks from Temple using Taquito?
I'm using Taquito with Temple wallet (prev. Thanos) i my dapp.
To connect the wallet I need to do wallet.connect(<name_of_network>).
If I'm using the wrong network name here I get an error from ...
0
votes
1
answer
41
views
How is a contract ID generated?
Let's say I have a raw transaction that I broadcast to the network. At what point does its operation hash (opHash) get generated? Is it when the baker is forming the block? And what are the inputs to ...
2
votes
0
answers
109
views
Random # Generating Smart Contracts
I've had an idea about being able to utilize effectively random #s on tezos, but I don't know if it's totally stupid and impossible to utilize, or a possible and really simple solution:
I need to ...
0
votes
1
answer
95
views
Cannot get transfer entrypoint
I'm trying to call an FA1.2 transfer function from another contract. Here is my endpoint in the FA1.2 contract:
type action is
| Transfer of michelson_pair(address, "from", michelson_pair(...
2
votes
1
answer
52
views
What different multisig contracts are supported by `tezos-client`?
What are the different multisig contracts are currently supported by tezos-client and which ones are planned to be supported? What is the difference between them and their respective hashes? Which ...
1
vote
2
answers
301
views
Listen for operations of a deployed contract
Coming from an ethereum web3 background, I'm accustomed to listening for a contract's events to figure out when things happen in my contract and react accordingly in the application.
I'm looking for ...
1
vote
1
answer
135
views
Why are formal proofs and verification important for smart contracts?
On the Ethereum blockchain, there is a lot of talk about formal proofs and verification of smart contracts. In particular, ERC20 tokens and various exchange contracts will mention that they are ...
1
vote
1
answer
177
views
Smart contracts - get tz address from signature like ecrecover ethereum
I want to be able to verify that a signature is signed by a public key's address in my smart contract method on tezos. For example with solidity see: https://ethereum.stackexchange.com/questions/2171/...
2
votes
1
answer
271
views
Tezos on a ERC20 Wallet
Sorry in advanced, my english is not the best. but i have to try.
Situation: I bought Tezos on the Binance App. Then i sent all the Tezos to my Wallet (ERC20 Wallet). Now its not showing on the wallet,...
0
votes
1
answer
205
views
proto.007-PsDELPH1.storage_exhausted.operation when originating contract (storage_limit is set)
I am trying to deploy a contract to delphinet with truffle.
On a local sandbox the contract deploys just fine, but for the deployment on Delphi I am getting:
proto.007-PsDELPH1.storage_exhausted....
0
votes
1
answer
100
views
"Invalid bytes error" on migration of PascalLigo contract
I am trying to write tests for my contract, which stores an user as follows:
type userData is record [
addressSet : set(bytes);
storedAmount : tez;
]
My storage is a big_map as ...
1
vote
1
answer
282
views
SmartPy Contract: Receive a balance?
I'm learning SmartPy and I'm trying to make a simple escrow contract. I read that contract.balance can be used to access the balance of a contract. In that case, how would I go about receiving XTZ to ...
1
vote
1
answer
76
views
How to resolve sp.TKey is not sp.TAddress error in SmartPy?
I have a function like this
@sp.entry_point
def _verifySigPersonalSign(self,req,sig):
sp.verify((req.deadline != sp.timestamp(0)) | (sp.now<=req.deadline), "request ...
1
vote
1
answer
82
views
How to compare timestamps in tezos smartpy?
req passed to _verifySigPersonalSign will be of type ERC
import smartpy as sp
ERC = sp.TRecord(sender=sp.TAddress,to=sp.TAddress,deadline=sp.TTimestamp)
class StoreValue(sp.Contract):
@sp....
0
votes
2
answers
92
views
How can I save the gas cost of operations when running contracts in sandbox pytest?
I am testing smart contracts in sandbox mode using python scripts.
I want to be able to store how much an operation cost. So for example when I get the output of a contract origination after baking a ...
1
vote
2
answers
191
views
Implementing Contract Metadata (tzip-16) on an already originated FA1.2 Smart Contract
Referring to the documents and examples of tzip-16, how would one implement the contract metadata on a Fa1.2 contract on SmartPy? In order to provide balance updates and offchain events.
2
votes
2
answers
336
views
How do I get method arguments using Taquito?
When I have a object of type ContractAbstraction<ContractProvider>, I can get a key/value map of all the endpoints in the deployed contract like this:
const contract: ContractAbstraction<...
1
vote
1
answer
58
views
How un/reliable is the timestamp provided by NOW in Michelson?
To which extend can bakers manipulate the timestamp Michelson uses for NOW?
I am not really sure how this value is provided to the smart contract and how reliable/unreliable it can be...
Is it safe to ...
1
vote
1
answer
84
views
What's the best way to convert from TMutez to TBytes?
Previously when I asked about converting types, I got this useful suggestion:
For mutez, you could start to convert to int (by dividing by 1 mutez) and then use the same techniques.
I'm wondering if ...
1
vote
1
answer
67
views
In a SmartPy smart contract, is there 'continue' or 'break' for loop?
In a SmartPy smart contract, is there 'continue' or 'break' for loop?
When I use 'continue' for loop, an error occurred. 'Error: invalid syntax'
2
votes
1
answer
90
views
How to create a contract which would delegate XTZs and receive rewards?
I am trying to write a contract that receives rewards from the baker using a default entry point and should only allow me to change the baker from a different entry point.
I am using the smartpy tool ...
2
votes
1
answer
30
views
Do on-chain contract calls happen atomically?
I have a couple of questions about on-chain contract calls:
Suppose two contracts call each other back and forth (let's say 5 times they transfer messages between them), but at on the last transfer, ...
1
vote
1
answer
37
views
How to format storage for a contract call with parameters?
I am trying to construct the storage needed to do an on chain contract call but I'm having trouble passing in the parameters. What is making it tricky is that one of the parameters is of type ...
1
vote
1
answer
34
views
How can I manually create an on chain contract call?
Using tezos sandbox mode, I am trying to test an on chain contract call in isolation of the main contract which calls it. If my contract was the Collatz template, it would like be trying to run the ...
1
vote
1
answer
34
views
SmartPy: How to test an invalid transaction sent from a contract call
I am testing a contract in SmartPy that uses a contract call (similar to the Collatz example).
Contract 'A' sends a transaction to contract 'B' with some data.
Contract 'B' does some computation and ...