I’m trying to access the keyset of a sender of a transaction without explicitly passing the publicKey as a string function parameter. I know that in the docs there is a (chain-data) function that returns the following object:
{“block-height”: 0,“block-time”: 0,“chain-id”: “”,“gas-limit”: 0,“gas-price”: 0,“sender”: “”}
I have tried using this and the sender always returns an empty string I have been interacting with my smart contract through a javascript front-end and have been hosting a blockchain instance locally on port 9001, as is outlined in the todo-mvc example in Kadena’s github. To interact with the contract I have been using pact-lang-api, and specifically the Pact.fetch.local() and Pact.fetch.send() functions, and in both cases the sender returns “”
Are there any best practices or workarounds for this?
(defun get-sender ()
(let (tx-data (chain-data))
[(at "sender" tx-data)]
)
)
;returns -> [""]
this is the javascript call:
test = (keyset) => {
const cmdObj = {
pactCode: `(contract.get-sender)`,
keyPairs: keyset
}
Pact.fetch.local(cmdObj, API_HOST)
.then(res => {
console.log(res.data);
})
}
//logs -> [""]
I am looking for it to return the sender's public key instead