Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Blockchain by (12.8k points)

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 => {




//logs -> [""]

I am looking for it to return the sender's public key instead

1 Answer

0 votes
by (29.8k points)

Hi, you can manually set sender information in the following way:

const cmds = {
                    keyPairs: KEY_PAIR,
                    pactCode: 'todos.delete-todos "id-1"',
                    meta: {
                      sender: KEY_PAIR.publicKey,
                      chainId: "",
                      gasPrice: 0,
                      gasLimit: 0
Pact.fetch.send(cmds, API_HOST)

Related questions


28.4k questions

29.7k answers


94k users

Browse Categories