Threads
December 20th, 2021
We have currently 10 threads for the above date.
🛠 │ dev-support
status - Resolved
ttnguyen --> <@!Benji | NEAR> Hi, I develop an FT tokens
ttnguyen --> I want to make storage deposit to CEO, CTO, etc
ttnguyen --> how can I do this
ttnguyen --> near call $ID distribute_tokens ‘{}’ --accountId $ID --depositYocto 1
ttnguyen --> If we have 3 person like CEO, CTO, CFO. We will need 3 yocto near
ttnguyen --> But storage deposit will assert if we send more than 1 yocto near
ttnguyen --> can we attach near in every single storage_deposit call
ttnguyen --> <@!bucanero> Can you help me answer my question?
bucanero --> if I understand your question, you want to create a FT, and assign some amount of tokens to certain users CEO, CTO, etc, is that right?
ttnguyen --> yes
ttnguyen --> I will transfer tokens to CEO, CTO, etc in 1 function
ttnguyen --> But we need call storage deposit first
ttnguyen --> and it throw error with attach_deposit
bucanero --> I see. I’m not a Rust developer, but let me take a look
ttnguyen --> Yes, I want to attach exactly 1 yocto near to the storage_deposit
ttnguyen --> <@!bucanero> Can you ask someone to help me
Benji | NEAR --> Just create a batch deposit function
ttnguyen --> can you show me an example
Benji | NEAR --> don’t have one on hand but just pass in a vector of accounts and then iterate through that vector and deposit for each user
Benji | NEAR --> you don’t need to assert 3 yocto btw. Asserting 1 (or at least one if you’re planning on the signer paying for storage) is fine.
ttnguyen --> Yes I want the signer pay for storage
ttnguyen --> I am not clear about the deposit function that you are talking about
ttnguyen --> <@!Benji | NEAR>
Benji | NEAR --> i’m looking at your code snippet above and that should be fine. What’s wrong with it?
ttnguyen --> Yeah, If I try to deposit 1 near, It will throw an error like this
ttnguyen --> And if I deposit 1 yoctonear it will throw this error
Benji | NEAR --> change ur assert 1 yocto to be assert at least one yocto
ttnguyen --> this assert belong to near standard
Benji | NEAR --> oh then you have a problem good sir
Benji | NEAR --> you can’t change the standards to fit your needs unfortunately 😛
Benji | NEAR --> you can create a new function however with the same logic and create a new assertion method
ttnguyen --> 😃)) Yeah then I will clone the storage management and then change to fit my logic 🙂
Benji | NEAR --> go team
ttnguyen --> 😃) Haha how about this function in real world?
ttnguyen --> When we do a ICO we will transfer tokens to buyers
ttnguyen --> They will call storage deposit on their own??
ttnguyen --> Like metapool
Benji | NEAR --> if that’s the way you write your contracts, yes.
ttnguyen --> I see meta pool have a button like this 😃)
🛠 │ dev-support
status - Resolved
Mouradif --> can an exported function in AssemblyScript take an enum
param? If so, how do I pass the parameter when calling the RPC?
For example for this contract
enum SomeTypes {
TypeA,
TypeB,
TypeONegative
}
export function addElement(name: string, type: SomeType) {
doStuff(name, type);
}
Would this work?
$ near call mycontract.testnet addEelement --args '{"name": "test", "type": "TypeA"}'
Dorian | NEAR --> Mmm I haven’t seen that done before.
Let me look in the near-skd-as
bucanero --> btw, enums are usually mapped to integer values
Mouradif --> oh that’s right
Mouradif --> so as long as I have the same enum on the client side it should be fine
bucanero --> yes, the client side should have the same enum
bucanero --> or the values for those enums
Mouradif --> and for the cli arguments just {"type": 0}
for typeA
bucanero --> correct
Mouradif --> gotha
Mouradif --> thanks
bucanero --> no problem 👍
bucanero --> depending on the client language, if the client can define some constants, then you could: #define MY_VALUE 1
and then {"type": MY_VALUE}
🛠 │ dev-support
status - Resolved
0xTracker.app --> has anyone done any work with a Python SDK for querying
Dorian | NEAR --> I haven’t, you’re trying to query the RPC?
0xTracker.app --> yeah I see the calls I guess just encoding/decoding the responses are going to be something that’s is written from scratch since no sdk exists
0xTracker.app --> I’d be up to the task but need some more info on how to send and receive the responses
0xTracker.app --> I’m not really too skilled with base64 stuff but might be time for me to get a better understanding ofi t
Dorian | NEAR --> That’d definitely be cool if you wanted to contribute in that way. I’ll bring this up to one of my team members and see where to best direct you with this endeavor
0xTracker.app --> A few users of my portfolio tracker is asking for NEAR support so would love to give them a way to view their assets.
Mouradif --> For querying the RPC you can use this https://github.com/near/near-api-py
Mouradif --> status: super rough but it should cover reading balances for fungible tokens if that’s what you need to do
0xTracker.app --> That’s I’ll give it a look over see if I can take some pieces out of it
🛠 │ dev-support
status - Unresolved
vmod --> <@!Benji | NEAR> can you help me with the deserialization thing
Benji | NEAR --> what was the deserialization thing again i don’t remember
vmod --> gimme a sec
vmod --> https://explorer.testnet.near.org/transactions/2vNeaNGx9ExsmqCKZkwCMLjGkwtbaSatBEcitx4sFVEc
Benji | NEAR --> oh this. I’ll ask the team if they’ve seen it before. My first guess is that it’s a wasm error
Benji | NEAR --> but i’ll ask
vmod --> this is the wasm
Mike Purvis | NEAR --> is this a Rust smart contract?
vmod --> yes
vmod --> any ideas?
Benji | NEAR --> no answer yet. I’ll ping you as soon as I get an answer
🛠 │ dev-support
status - Resolved
bosnic --> weird layout in the dev docs: when you have AssemblyScript selected under Smart Contracts > Tutorials, you can see “FTs” as a folder. When you switch to rust it disappears. Not sure if reported already
Benji | NEAR --> This is because rust expands and pushes the FTs section downwards
bosnic --> FTs doesn’t show up in my browser at all with those pages selected, even when I collapse the rust section
bosnic -->
bosnic --> not a big deal, just thought that was odd
Benji | NEAR --> you’re in two different directories
Benji | NEAR --> this is the develop category:
Benji | NEAR --> this is the tutorials directory
Benji | NEAR -->
🛠 │ dev-support
status - Unresolved
Mouradif --> <@!Dorian | NEAR> if you ever cross an example with chaining contract calls (using ContractPromise.then
method) where one contract call would manipulate the result of the previous one, I’m super interested
Dorian | NEAR --> I’ll look around and let you know if I find one!
This has also prompted me to make a new example on this topic haha
Mouradif --> In terms of project architecture for NEAR, does it make sense to split a project into multiple contracts? I got this habit for Ethereum in order to have some contracts hold less information in their storage and make some transactions cheaper (the ones that need to perform complex lookups in the data stored). But for NEAR I’m starting to think that the amount of data stored is the main relevant metric and in that case, splitting the project in multiple contracts would actually incur more storage
Benji | NEAR --> it really depends on the use case. Sometimes it might be a good idea and sometimes it might not be such a good idea. Deploying multiple contracts is going to cost you more storage for sure but if it increases the UX, might not be a bad idea.
vmod --> Multiple smart contracts might also be easier to scale if you need recursive stuff
vmod --> like deploying
Mouradif --> that’s exactly what I need
vmod --> What are you trying to do
Mouradif --> a decentralized domain name service
vmod --> why do you need recursion for that
Mouradif --> I want the ability to delegate the management of a subdomain to another contract (which would implement the same interface)
Mouradif --> like for the domain hello.sometld
I can have the records
@ 6000 IN A 1.1.1.1
subdomain 6000 IN REC my.own.deployed.contract.near
(where REC
means Recursion)
where subromain.hello.sometld
would have
@ 6000 IN A 1.1.1.2
sub-subdomain 6000 IN A 1.1.2.2
making sub-subdomain.subdomain.hello.sometld
pointing to 1.1.2.2
but the contract at my.own.deployed.contract.near
can also have REC
records that point to other contracts
vmod --> so youd have a contract per domain?
vmod --> why not use a LookupMap or something
vmod --> oh
vmod --> ic
vmod --> ok
vmod --> Yeah I guess multiple smart contracts makes sense here
vmod --> do you autodeploy
vmod --> them
Mouradif --> so basicly, the default case is that I have everything in one contract
Mouradif --> but I want to allow people to deploy their own contract (as long as they implement the interface) and link them to that “main” contract for one subdomain
Mouradif --> otherwise yeah if I can’t figure out this promise chaining thing, I may just give up that idea
vmod --> https://www.near-sdk.io/promises/deploy-contract
vmod --> You know how to use promises right
Mouradif --> JS promises yeah ^^
vmod --> oh
vmod --> are you putting Rust Promises in the smart contracts?
Mouradif --> the ones that you can await
if you’re in an async context or pass a callback to their .then()
function
vmod --> because that might be what you are looking for
Mouradif --> I unfortunately don’t write in rust
vmod --> oh
vmod --> do you use as then?
Mouradif --> yeah
vmod --> Is there a way to deploy contracts through AS api
Mouradif --> yes quite similar too
vmod --> are you using that
Mouradif --> but that’s not the part I’m worried about, I found how to deploy contracts and I’m actually not even using it in my project
Mouradif --> I’m stuck at the part where I want to call a method in another contract and do something with the result before returning it
Mouradif --> Having not found what I’m looking for, I went to get the info straight at the source and this is where the trail ends: https://github.com/near/near-sdk-as/blob/f3707a1672d6da6f6d6a75cd645f8cbdacdaf495/sdk-core/assembly/env/env.ts#L127
Mouradif --> I’m trying hard not to lose hope
Benji | NEAR --> cc <@!Dorian | NEAR> sorry I don’t know much about AS at all 😦 I wish I was more help. Perhaps <@!sirwillem> has some input?
Mouradif --> I’ve given him enough headache for one day xD all I can do now is wait for an example ^^ https://discord.com/channels/490367152054992913/542945453533036544/922589427056902186
Dorian | NEAR --> Yeah I’d say let’s long Willem
<@Mouradif> how would you best describe your Q one more time so i can pass it along? 🙂
Mouradif --> From a contract, I’m trying to call a method in another contract and perform some operations on the result before returning it. Like for example in the Calculator
and Calculator Caller
example here: https://docs.near.org/docs/tutorials/contracts/cross-contract-calls I would like an example where the Calculator Caller
would have an extra method that adds the 2 numbers and appends some string before returning like so :
const OTHER_CONTRACT = "dev-REPLACE_THIS_IDENTIFIER";
export class CalculatorApi {
add(a: string, b: string): ContractPromise {
let args: AddArgs = { a, b };
let promise = ContractPromise.create(OTHER_CONTRACT, "addLongNumbers", args.encode(), 100000000000000);
logging.log("OTHER_CONTRACT: " + "(" + OTHER_CONTRACT + ")")
/***************************************************************************************/
/****** Here say I want to append some string to the result before returning it ********/
return promise;
}
}
Dorian | NEAR --> So in a more general sense you are trying figure out how to do a cross contract call to a method in another contract where you are performing additional operations?
Mouradif --> additional operations on the result of the cross-contract call
Mouradif --> the thing is, all the examples I’ve seen where a contract (A) calls another contract’s method (B:foo) in AssemblyScript, the result of B:foo is always returned as is. It doesn’t even seem possible to retrieve that result in contract A but I’ve seen how it’s possible in Rust so I have hope ^^
🛠 │ dev-support
status - Unresolved
samauel --> Hello can someone help me with distribution of near token?
samauel --> I was in the ico but still have not recieved my tokens can someone please help me?
samauel --> I had emailed someone named kendall which said she will handle the distribution. But her email seems to no longer be working as i am trying to contact her again
samauel --> My account name is auel.near and i have already filled out the form, again can someone here please assist me in this matter??
🛠 │ dev-support
status - Unresolved
bosnic --> I’m testing a contract that implements ft_on_transfer
and uses the msg
parameter. The contract is written to panic if that parameter is not passed, but I was able to complete a transfer with a fungible test token:
token receiver: https://github.com/currence-team/currence-contract/blob/master/market/src/token_receiver.rs#L21-L25
transaction: https://explorer.testnet.near.org/transactions/FnzBsvr42zUnFQbaynEgecbrkPyCoSH2L5fuVMRQxu6N
Benji | NEAR --> it doesn’t look like it’s calling ft_on_transfer
bosnic --> the token I’m using is the example FT from the docs: https://github.com/near-examples/FT/blob/master/ft/src/lib.rs
Does the token contract need to implement something to call ft_on_transfer
? I understood from the spec that all receiving contracts need to implement that interface
Benji | NEAR --> if you just call ft_transfer
it will only transfer tokens. You need to be calling ft_transfer_call
which will both transfer the tokens AND call the ft_on_transfer
method on the receiver’s contract.
bosnic --> ah I was using ft_transfer, thanks
bosnic --> <@!Benji | NEAR> I added some logging to the contract in order to debug issues for a FT transaction. Where can I see the logs from the contract failing in ft_on_transfer
?
https://explorer.testnet.near.org/transactions/D5Bf8tURQr7GtCBXYQNysbuA95WNHeRuHuGaDGtfRHjd#9XAbXmQPhL4AtRRHKYu9cXt14JsudunsgnGgCMB2hyZ1
Benji | NEAR -->
bosnic --> I believe ft_on_transfer
is failing since if I don’t include a msg
it’s panicking as expected
bosnic --> I have logging that happens before any subtraction in the receiving contract, but the error I see there appears to be in the token contract showing a panic from calling the receiving contract. Will there be visible logs from the receiving contract?
Benji | NEAR --> I bet you everything I own that it’s this line right here :p
🛠 │ dev-support
status - Resolved
Benji | NEAR --> https://github.com/near/near-sdk-rs/blob/ddc5b142130e69dd9aa2cd264ba316282273af35/near-contract-standards/src/fungible_token/core_impl.rs#L180
Benji | NEAR --> I bet you that you didn’t attach enough GAS
Benji | NEAR -->
Benji | NEAR --> yup
Benji | NEAR --> https://github.com/near/near-sdk-rs/blob/ddc5b142130e69dd9aa2cd264ba316282273af35/near-contract-standards/src/fungible_token/core_impl.rs#L12
Benji | NEAR --> this line here shows the value of GAS_FOR_FT_TRANSFER_CALL
Benji | NEAR --> it’s 30 TGas
Benji | NEAR --> you attached 10 TGas to the call
Benji | NEAR --> and so the line I linked first is trying to do 10 TGas - 30 TGas
Benji | NEAR --> which overflows
Benji | NEAR --> cuz negative number
bosnic --> RIP
Benji | NEAR --> hahah hey you live and you learn 😛 that’s why we’re here!
Benji | NEAR --> try attaching 50 TGas
Benji | NEAR --> 30 TGas won’t work btw ^
Benji | NEAR --> you need more than that
Benji | NEAR --> so 50 might be good enough
Benji | NEAR --> just test her out and see
bosnic --> that was enough!
Benji | NEAR --> Go team!
🛠 │ dev-support
status - Resolved
bosnic --> <@!Benji | NEAR> same question: in the case of this transaction that succeeded, where do I find logs from the receiver contract? tx: https://explorer.testnet.near.org/transactions/GVE3qqyQesf5pGiWfUTrAUnGba7EJSu8tBtYx25qTLW8
Benji | NEAR --> they’ll show up right below the return value of the functions in the explorer
Benji | NEAR -->
Benji | NEAR --> right at the bottom
bosnic --> ah missed that one line, thanks