0

I'm trying to create a contract that communicates with JIRA API through Chainlink Oracle on the Goerli Network. The interaction should create a JIRA project, then write some of the returned JSON's data into the blockchain.

Heres my contracts:

JIRA Manager (Called Fractal Forge Manager):

    pragma solidity ^0.8.0;

import "@chainlink/contracts/src/v0.8/ChainlinkClient.sol";
import "@chainlink/contracts/src/v0.8/ConfirmedOwner.sol";
import "../game/GameData.sol";

contract FractalForgeManager is ChainlinkClient, ConfirmedOwner {

    address public constant EMPTY_ADDRESS = 0x0000000000000000000000000000000000000000;

    //Chainlink config
    using Chainlink for Chainlink.Request;

    address private oracle;
    bytes32 private jobId;
    uint256 private fee;

    // Fractal Forge Data:
    GameData[] public projectList;

    /**
     * Goerli Testnet details:
     * Link Token: 0x326C977E6efc84E512bB9C30f76E30c160eD06FB
     * Oracle: 0xCC79157eb46F5624204f47AB42b3906cAA40eaB7 (Chainlink DevRel)
     * jobId: 53f9755920cd451a8fe46f5087468395
     */
    constructor() ConfirmedOwner(msg.sender) {
        setChainlinkToken(0x326C977E6efc84E512bB9C30f76E30c160eD06FB);
        setChainlinkOracle(0xCC79157eb46F5624204f47AB42b3906cAA40eaB7);
        jobId = "53f9755920cd451a8fe46f5087468395";
        fee = (1 * LINK_DIVISIBILITY) / 10; // 0,1 * 10**18 (Varies by network and job)
    }

    /**
     * Create a Chainlink request to retrieve API response, find the target data
     */
    function createGameProject(string memory projectName, string memory projectKey) public returns (bytes32 requestId)
    {
        Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.fulfillMultipleParameters.selector);

        // Set the URL to perform the POST request on
        request.add("post", "https://latinosystems.atlassian.net/rest/api/latest/project");
        request.add("body", string.concat("{",
        "\"key\": \"",projectKey,"\",",
        "\"name\": \"",projectName,"\",",
        "\"projectTypeKey\": \"software\",",
        "\"leadAccountId\": \"557058:aed543b7-1ccc-4eea-9eb5-07fb1a44da29\",",
        "\"projectTemplateKey\": \"com.pyxis.greenhopper.jira:gh-simplified-agility-scrum\"",
        "}"));

        request.add("path", "key");

        // Sends the request
        return sendChainlinkRequest(request, fee);
    }

    function fulfillMultipleParameters(bytes32 requestId, string memory key) public
    {
        GameData newGameProject = new GameData(key);
        projectList.push(newGameProject);
    }

    function getProjectList() view public returns(GameData[] memory)
    {
        return projectList;
    }

    function getGameDataByKeyName(string memory key) view public returns(GameData)
    {
        return projectList[0];
        for(uint256 i = 0; i < projectList.length; i++)
        {
            if(keccak256(bytes(projectList[i].gameJiraKey())) == keccak256(bytes(key)))
            {
                return projectList[0];
            }
        }
        revert('Not found');
    }
}

ProjectData (called game data)

//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

contract GameData
{
    struct GameBounty
    {
        string jiraTaskID;
        uint256 bountyPrice;
        uint256 jiraScore;
    }

    string public gameJiraKey;
    GameBounty[] public bounties;

    constructor(string memory createdGameJiraKey) public
    {
        gameJiraKey = createdGameJiraKey;
    }

    function calculateTotalPoints() public view returns(uint256)
    {
        uint256 totalScore = 0;
        for(uint256 i = 0; i < bounties.length; i++)
        {
        }

        return totalScore;
    }
}

Through brownie, I tried to call FractalForgeManager's createGameProject right after deploying the contract, adnd themethod was called but it just didn't register anything on the blockchain. To further test, I simply called the already existing contract like this:

self.fractalForgeManager = FractalForgeManager.at(address)

Then tried calling the createProject method

self.fractalForgeManager.createGameProject(projectName, projectKey)

But when I try to call createGameProject, I get the following error (my contracts are funded and I have eth on my test wallet):

Running 'scripts\deploy\Deploy.py::main'...
<scripts.deploy.DeployJiraConsumer.DeployJiraConsumer object at 0x000001D1FC00CC70>
  File "C:\Users\Levant\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\_cli\run.py", line 51, in main
    return_value, frame = run(
  File "C:\Users\Levant\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\scripts.py", line 110, in run
    return_value = f_locals[method_name](*args, **kwargs)
  File ".\scripts\deploy\Deploy.py", line 17, in main
    print(deployJiraconsumer.createProject("TestProject1", "TestProject"))
  File ".\scripts\deploy\DeployJiraConsumer.py", line 25, in createProject
    self.fractalForgeManager.createGameProject(projectName, projectKey)
  File "C:\Users\Levant\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py", line 1864, in __c
all__
    return self.transact(*args)
  File "C:\Users\Levant\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py", line 1732, in tra
nsact
    raise AttributeError(
AttributeError: Final argument must be a dict of transaction parameters that includes a `from` field specifying the sen
der of the transaction

Any idea what the issue may be here?

1 Answer 1

1

Solves, just added a map with "from"and "account" at the endof my method's parameters.

self.fractalForgeManager.createGameProject(projectName, projectKey, {"from": self.account})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.