How to get the sender address using Pact? - pact-lang

When using solidity I can get the sender address by using msg.sender and when using ink smart contracts I can use Self::env().caller();
Can anyone advise what the equivelent would be for Pact? I've had a look at some of the documentation but I think I must be missing it.
Appreciate any guidence you can give.
Thanks,
KB

(chain-data) is a function that returns some metadata of your transaction. It's documented in the Pact language reference:
https://pact-language.readthedocs.io/en/latest/pact-functions.html#chain-data
You can get the sender value from the function like this:
(at 'sender (chain-data))

Related

Can I query a Near contract for its method signatures?

Is there a way to query what methods are offered by a given NEAR contract? (So that one could do autodiscovery of some standard interface, for instance.) Or do you have to just know the method signatures already before you can interact with a contract?
No not yet. Currently all contract methods have the same signature. () -> () No arguments and nothing is returned. Each method has a wrapper function that deserializes the input bytes from a host; calls the method; and serializes the return value and passes the bytes back to the host.
This is done with input and value_return. See input..
There are plans to include the actual signatures of the methods in the binary in a special section, which would solve this issue.
NEP-351 was recently approved, which provides a mechanism for contracts to expose all standards they implement. However, it is up to contract developers to follow this NEP. When integrated into the main SDK, I presume most will.
Alternatively, there is a proposal to create a global registry as a smart contract that provides this information.
Currently, there is not.
You will need to know what contract methods are available in order to interact with a smart contract deployed on NEAR. Hopefully, the ability to query available methods will be added in the near future.
I suppose you can just include a method in your own contracts that returns the other method signatures in some useful format: json or whatever
you would have to make sure that it stays current by maybe writing some unit tests that use this method to exercise all others
I suppose this interface (method and unit tests) can be standardized as an NEP in the short term until our interface becomes discoverable. any contracts that adhere to this NEP must include this "tested reflection method" or "documentation method" or whatever it would be called

What is the difference between MongoRepository and MongoOperation.

I am doing one POC and got confused what should i use either MongoRepository or MongoOperation beacuse internally both uses MongoTempletes only. Please suggest with proper example.Thanks in advance :).

What is the correct place to list and examine ports in erl_driver

In the tutorial for erl_driver there seems to be no indication to where does the first ErlDrvPort object comes from. Say I want to wrap libusb-1.0 to use it from erlang. There is no place in the API described by ErlDrvEntry for any index methods. How does one find a port to open?
Normally you obtain the first port using the erlang:open_port/2 function, usage of which is shown in the code example in section 6.2 of the tutorial you linked to in your question.
Instead of using Ports to wrap a C library, you can also use NIFs. With Nifty there exists even a wrapper generator that does most of the work for you.

Message format in Channel API (GAE)?

I'm working on a HTML5 collaborative canvas drawing tool on GAE. Essentially people draw, send their coordinates and their motion to GAE through channel API and then other people receive the updates.
As required by the GAE documentation, I have a function in my javascript code to collect messages received from the server:
socket.onmessage= function (message) {
var s=message.data;
//Extract X,Y,motion out of s and Draw(x,y,motion)
};
However, the message data I'm sending are actually x and y coordinates and a string of either ("start"/"drag") in the form of:
x=505.0000457763672&y=111.66667175292969&type=start
I actually have no idea about any of the variables or features in this 'message' class and I wouldn't know to use 'message.data' if I didn't see it in someone else's source code - is this actually documented anywhere? I'd like to be able to use the substring features to effectively extract the 3 values but they don't seem to work with message.data.
Any idea if there are detailed documentations on the full member functions/classes/variables documentation on the message class?
Any input is much appreciated!
I wouldn't say it's documented WELL, but it is documented in the channels API docs:
https://developers.google.com/appengine/docs/python/channel/javascript
It specifically does say the message object has a parameter called 'data'.
You should be able to use javascript substring features just fine, but unless you show your code, no one will be able to help you with that.

Labjack Humidity Probe Example

I realize this might be a long shot, but does anyone have an example of using the EI-1050 probe with a Labjack controller in something C-related? I'm currently using a Labjack U12 if it matters.
It installed 2 examples, ljsht and ljsht-multi, that seem to be doing something related to it, but I can't find the source code.
Thank you for your time.
The applications you mentioned are written in LabVIEW, and the source code is available. Use LJSHT.exe to make sure your EI-1050 is connected right and giving good readings.
Refer to the EI-1050 datasheet for information about interfacing with the U12.
Then start with a basic C example like "VC6 Simple Example" or "U12 Dev-C++ Example":
http://labjack.com/support/u12/examples
... and add a call to the function SHT1X() described in Section 4.31 of the U12 User's Guide.

Resources