Questions tagged [near-sdk-rs]

13 questions
6
votes
2 answers

In NearProtocol, how to migrate contract state

Assume there's a contract written in near-sdk-rs, deployed, has state defined as: #[near_bindgen] #[derive(BorshDeserialize, BorshSerialize)] pub struct NFT { pub tokens: UnorderedMap, } #[derive(BorshDeserialize,…
Bo Yao
  • 136
  • 4
3
votes
1 answer

How to link a WASM binary inside near-sdk Rust code that targets WASM

I have a WASM function that I want to use in my near-sdk Rust project that targets WASM. How can I call this function inside my Rust code?
eduardogbg
  • 553
  • 4
  • 18
2
votes
3 answers

NEAR-sdk #[near_bindgen] colliding with other macros

I've put together a minimum working example, and you can see it here: https://github.com/synthesis-labs/near-mwe. In summary: I have a simple macro that checks that the owner (an arbitrary definition in the context of a struct of the contract) has…
Mike
  • 59
  • 5
2
votes
1 answer

What type to use for big numbers?

Reference to my smart contract file: https://github.com/amirsaranBIH/nearkick/blob/13-create-logic-for-users-to-remove-themselves-from-projects/contract/src/lib.rs My main state struct looks like this: #[derive(Serialize, Deserialize,…
Amir Šaran
  • 406
  • 1
  • 4
  • 14
1
vote
1 answer

nearprotocol - best way to pay transaction fees for contract users

I want to pay all costs for some contract users (probably forever). The idea is to incorporate more users in NEAR ecosystem and provide them the ability to use my contract for free for easier onboarding. The scenario similar to the one described in…
Vsevolod
  • 87
  • 6
1
vote
1 answer

How can I insert a key-value pair in an unordered map that is present in the innermost struct in rust programming language?

This is my data model: pub struct RaffleDetails { prize: Balance, start: Timestamp, end: Timestamp, participants: UnorderedMap, } pub struct RaffleDapp { raffles: UnorderedMap
user702991
  • 33
  • 4
1
vote
2 answers

How to select a random key from an UnorderedMap in NEAR Rust SDK?

How can one get a random key from an UnorderedMap in NEAR Rust SDK?
user702991
  • 33
  • 4
1
vote
2 answers

How can I serialize a near-sdk-rs LookUpMap that uses a String as a key, or is there a better way?

I am adding a feature to the Sputnik DAO v2 near contract to map tokens to a number of votes. Here is my constructor: #[ext_contract(ext_self)] pub trait Contract { fn exchange_callback_post_withdraw(&mut self, sender_id: AccountId, token_id:…
Rashi Abramson
  • 1,127
  • 8
  • 16
1
vote
1 answer

How to add new properties to a NEAR Rust smart contract that already has state?

I have a Rust smart contract deployed to NEAR protocol, and now I want to update it and add properties for persistence. But the contract does already have state, and if calling the new version I get the error Cannot deserialize the contract…
Peter Salomonsen
  • 5,525
  • 2
  • 24
  • 38
0
votes
1 answer

near-sdk-rs - unit testing promises

What is the right (intended) way to test promises and their results in near-sdk-rs? Please, point me in the right direction (docs/examples/...). Let's take the simplest example (from here https://www.near-sdk.io/promises/token-tx):…
Vsevolod
  • 87
  • 6
0
votes
1 answer

Is there a way to call NonFungibleTokenCore from an external contract in NEAR using ext_contract?

I am using functions called on the dependency trait NonFungibleTokenCore and I would like to use the convivence wrapper of ext_contract to simplify cross contract calls. Here is my attempt to add it: #[ext_contract(ext_non_fungible_token)] trait…
Rashi Abramson
  • 1,127
  • 8
  • 16
0
votes
1 answer

Sputnik v2 throws "account doesn't exist" error when creating contract, adding account doesn't fix it. Tips?

I am upgrading the DAO to use version 4 of the near sdk. During the migration I needed to change the way the AccountId struct was used, from being a string to being a struct that holds a string. The original test has a token id of an empty string,…
Rashi Abramson
  • 1,127
  • 8
  • 16
-1
votes
1 answer

How can I transfer a token from a contract to a wallet from within the contract

So I am trying to transfer a FT, saved as a file ft.rs, which is generated in the standard way, like so: impl Contract { /// Initializes the contract with the given total supply owned by the given `owner_id` with /// default metadata (for…
AKRA
  • 300
  • 2
  • 12