Skip to main content

Questions tagged [smartpy]

Discussion about the SmartPy language

Filter by
Sorted by
Tagged with
0 votes
1 answer
165 views

Initiate a field in the storage of a contract with the source address of origination

I have the following smart contract where I pass admin address in the init function of the smart contract: (you can run it on smartPy online editor) class SC(sp.Contract): def __init__(self, ...
0 votes
1 answer
21 views

got HTTPError while imporing

i am getting http error while importing fa2 library. i checked link and it says host error. did it moved to new address? File "./contracts/src/something.py", line 3, in FA2 = sp.io....
0 votes
2 answers
71 views

Decoding sp.pack("address") outside of chain

I have a question , While packing the string, "KT1FRoFxDhnKXGPggejHPAnMs27j6rcVfwzV", the output is 0501000000244b543146526f467844686e4b5847506767656a4850416e4d7332376a3672635666777a56 this ...
2 votes
1 answer
131 views

How to use internal hacks to convert from String to Address (or from Address to String) in SmartPy

There is a similar question but it does not fully answer this question. In the answer for that question posted here there is mention that while it is officially not possible it is actually technically ...
0 votes
1 answer
16 views

sp.contract can get only explicit string as an entrypoint

I'm trying to call another contract from mine. It seems like I can't feed sp.contract with an entrypoint string that comes from an argument (it works perfectly fine with an explicit string like "...
1 vote
1 answer
73 views

Using the token_metadata @offchain_view to load tzip-21 compliant metadata

Are there any downsides to how I'm declaring the token_metadata in the @offchain_view below? Loading the data from storage appears to work as expected when testing it on tzcomet and BCD, though I just ...
1 vote
2 answers
124 views

Send tezos to contract address after origination using conseiljs

I am trying to send tez from my tz1-AAA account to KT1-AAA contract address means I want my contract address to hold some tez. Disclaimer - I have knowingly replaced some part of address with "....(s)...
1 vote
2 answers
193 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.
0 votes
2 answers
58 views

Error: TezosOperationError: (branch) proto.017-PtNairob.contract.empty_transaction

So, i'm doing the royalties function for my NFT Marketplace. My idea was to make a big map with the royalties (user and amount) for each new token created, and it's working fine. My problem is when i'...
0 votes
1 answer
34 views

Programatically create Tezos Wallet

Hi guys inside my ICO website I want to create on the fly a tezos compliant wallet with the custom tokens for people once they purhcase. Is there a way to programatically create a wallet thanks peeps?
0 votes
1 answer
24 views

Two contract interactions same time?

So, i want to list my NFT, so, i update operators and then update my metadata. The problem is i need to accept two times, one to update operators, other to update (list) in metadata. Is that a way to ...
0 votes
2 answers
42 views

Error: Uncaught (in promise) TezosOperationError: (temporary) proto.017-PtNairob.tez.subtraction_underflow

Error: Uncaught (in promise) TezosOperationError: (temporary) proto.017-PtNairob.tez.subtraction_underflow I know this error is caused by a subtraction resulting in a negative number, but i'm just ...
0 votes
1 answer
43 views

calling a FA2 smart contract transfer entrypoint from my contract in smartpy

Hello guys I am trying to call from my contract entry point from FA2 token contract that I have deployed. But I am unable to find anything on the internet. The only thing I found from the ...
0 votes
1 answer
25 views

How to access contract metadata from another contract?

I'm building a NFT Marketplace. I already set the mint function (with editions), list and buy function. Now i'm trying to build the auctions functions. On Smartpy, i created the Marketplace class, and ...
0 votes
1 answer
35 views

How to set Total Supply on TzKT?

I'm trying to create multi-edition items. My idea was to make a list of each token and then each token edition with the owner. Ok, i create the item and shows like that on blockchain: https://api....
0 votes
1 answer
44 views

Error: Error in Scenario / Assertion failed

I am doing a contract to Mint Nfts on Tezos on Legacy SmartPY ide (because Tezos tutorial uses it). I already created Nfts but only in single edition, now i'm trying to do a Multi-edition, but the IDE ...
-2 votes
3 answers
245 views

Fraudulent Smartpy Charges on my credit card

For two months now I have been charged for Smartpy Smart Browser that I didn't ask for or sign up for. Can someone help me get to the bottom of this.
0 votes
2 answers
37 views

Url error in smartpy

I trying to write a smart contract on the tezos network and using import FA2 library for this. But when I try to run the code I face the url error. this is my code : import smartpy as sp FA2 = sp.io....
0 votes
1 answer
33 views

testing contract inside smartpy test initializing by contract address

While testing on smart contract file by adding scenario, @sp.add_test("IntegrationTest") def test(): sc = sp.test_scenario() helper_contract = deploy_helper_contract() ...
0 votes
1 answer
21 views

Integrate a url in an NFT during the mint

I would like to add the possibility when I mint an NFT to integrate a "URL" in the parameters of the NFT. For this I tried to modify my mint function in my smart contract like this: @sp....
0 votes
1 answer
53 views

NFT transfer functionality with Smart Contract

I created a smart contract thanks to the documentation on tezos: https://tezos.com/developers/tutorials/nft-markeplace I wanted to be able to test the transfer functionality of nft between users or ...
1 vote
1 answer
41 views

How to transfer an NFT

I'm trying to transfer an NFT, that I just minted to someone without them paying for it (just like an exchange). Here is the function I created on smartpy: @sp.entry_point def transferTest(self, ...
0 votes
1 answer
33 views

How to handle oversized operation while originating contract?

I was trying to originate a smart contract from legacy smartpy CLI. I got this error: [INFO] - Using RPC https://ghostnet.ecadinfra.com... { "message": "Http error response: (500) [{...
0 votes
1 answer
10 views

Is there any other way than using lazify to update contract if i find any issue later?

How can we update a SmartPy contract. One way is through lazify but is there any other way to to so?
1 vote
3 answers
58 views

checking if the number is negative or not

I have a requirement where I need to pass a byte into a function and that function should convert that byte to integer and returns true if it is negative else false. the function will be this in the ...
0 votes
1 answer
60 views

big endian order in smartpy

def tb(l): return b''.join(map(lambda x: x.to_bytes(1, 'big'), l)) The above function takes a list of number and is being converted into bytes, and the returned value is used this way, base58....
1 vote
1 answer
39 views

rlp encoding of solidity

there are two functions on solidity function encodeString(string memory self) internal pure returns (bytes memory) { return encodeBytes(bytes(self)); } /** ...
2 votes
1 answer
41 views

Pytezos balance_of entrypoint function for fa2 tokens

I was trying to implement a balance_of function. According to the documentation, it should be looking like this $balance_of: { "requests": [ $requests_item, … ], &...
0 votes
1 answer
54 views

Callback function getting issue

I have two contracts , contract A and Contract B. This is my contract B where I have defined a callback function that will return sp.some("test") when called. import smartpy as sp ...
2 votes
1 answer
53 views

Smartpy 0.18.0 FA2 template

I am looking for the FA2 template with the new syntax in version 0.18.0 and above in smartpy. Is there something already available as the token template in the smartpy template are using old version. ...
0 votes
1 answer
26 views

Trying to give a custom metadata but still it is using the default base metadata mentioned in class Common

Hello I am using the template Fa2NFT library. When we add the compilation target we need to give it a metadata parameter. I am trying to give it a custom metadata but still it is using the default ...
0 votes
1 answer
32 views

Do I always have to write the argument names in SmartPy tests?

I defined an entrypoint with 2 arguments: @sp.entrypoint def update(self, newx, newy): self.data.x = newx self.data.y = newy then I wrote a test of this entrypoint: scenario += contract....
1 vote
1 answer
26 views

rlp decoding not working as expected

I have a rlp encoded data and am trying to decode it with Accurast library Utils = sp.io.import_script_from_url("https://raw.githubusercontent.com/Acurast/acurast-hyperdrive/main/contracts/tezos/...
0 votes
1 answer
41 views

trying to access a callback function

I am trying to read a balance_of function of fa2 contract and updating my storage with the balance. but I am getting an issue Error: Type Error sp.TList(sp.TPair(sp.TPair(sp.TAddress, sp.TNat), sp....
0 votes
1 answer
52 views

call another contract onchain view

first we deploy fa2 contract from a contract like this deployed_fa2 = sp.create_contract_operation(contract=FA2_contract.SingleAssetToken(admin=sp.self_address, metadata=metadata,token_metadata=...
0 votes
1 answer
25 views

Error: Error in Scenario File "smartML/michelson_base/typing.ml", line 206, characters 27-33: Assertion failed

i was writing a HTLC contract and using a scenario when this error shows up: Error: Error in Scenario File "smartML/michelson_base/typing.ml", line 206, characters 27-33: Assertion failed . ...
1 vote
1 answer
49 views

RLP decoding on tezos

I have a code where a string "TEST" is encoded using RLP, https://smartpy.io/ide?cid=QmNVpo55Ss43aZiyrkdbEWcmmQEAsR2qHLKsPcLbqie7yu&k=8d516a673d972f3204f0 How do we decode the obtained ...
1 vote
1 answer
38 views

Do we have allowance() method like solidity in smartpy?

I need to implement allowance() function of Solidity, how can we achieve it in SmartPy?
1 vote
1 answer
128 views

Error in Inter contract call from a contract to quipuswap dex2 contracts swap entrypoint

I have written smartpy code to call an entrypoint swap on quipuswap dex v2 smart contract. Here is the code for that @sp.entry_point def swap_tokens(self, amount_in, min_amount_out, direction):...
1 vote
1 answer
160 views

Problem when deploying smart contract

I've been trying to create a smart contract on the Tezos blockchain for several times. I was never able to create a smart contract on this blockchain because of this error. I use the code that is in ...
2 votes
2 answers
121 views

Can I create an on-chain view that calls another contract's on-chain view and return it?

I have two contracts contract_one and contract_two. On contract_two I have an on-chain-view defined like this: @sp.onchain_view() def get(self, id): sp.result(self.data.map[id]) This view works ...
1 vote
1 answer
29 views

Unable to fetch view `get_swap_min_res` from quipuswap v2 pool using smartpy

I was trying to use views in the v2 contract of quipuswap. This is my code. But getting the error while executing. Can someone spot where I am going wrong? Code: @sp.entry_point def ...
0 votes
1 answer
64 views

Calculation complex mathematical expressions in smartpy like ln, log, etc

I want to calculate complex mathematical expressions such as ln(94) in smartpy. How can this be done?
0 votes
2 answers
72 views

TezosOperationError: (permanent) proto.016-PtMumbai.michelson_v1.bad_stack

I am getting following issues: compilation warning: [warning] Error in generated Michelson contract: previous error deployment error: "TezosOperationError: (permanent) proto.016-PtMumbai....
0 votes
1 answer
70 views

How to get XTZ balance of a address?

I want to read available tezos balance of a given address. How do we achieve this in smartpy? Also do we have allowance() method like solidity in smartpy?
1 vote
2 answers
36 views

Data type mismatch

I have two codes, Utils = sp.io.import_script_from_url("https://raw.githubusercontent.com/RomarQ/tezos-sc-utils/main/smartpy/utils.py") sp.len(sp.bytes("0x0001")) Utils.Int....
0 votes
2 answers
22 views

How to implement a simple hashlock contract with initial commit of a sha256 hash of a password string

Im trying to implement a simple hashlock contract where I initially commit a sha256 hash of a password string and an address of the target receiver. The contract compiles and tests work (since for ...
1 vote
1 answer
78 views

Tracking gas consumption by an entrypoint in smartpy during tests

I want to check how much gas an entrypoint consumes when we perform a transaction when writing tests in smartpy. How can this be done? Smartpy documentation too doesn't have anything that can help.
0 votes
3 answers
204 views

Conversion of address to bytes

I converted contract address to bytes using pack , and the result is this 050a00000016014b168ccb96310249aade4ce010e4e2ec8dd4602900 pasting this on online byte to string tool shows an error Invalid UTF-...
-1 votes
2 answers
24 views

sp.if: cannot unify branches

I am getting "sp.if: cannot unify branches" error from a onchain view method. Below is the code snippet. Full error msg: [error] Type Error sp.TRecord( locked_balance = sp.TNat, ...

1
2 3 4 5