0

Subgraph indexing failing due to mapping abortion with reason - ethereum value is not an address, from one of the handlers. I understand the issue if from the handlePaymentExpenseCreated() function but I'm unable to pinpoint the issue. Everything seems right. Thank you in advance. Here's the image of the logs.enter image description here

The subgraph schema

type ActiveExpense @entity {
  id: ID!
  payer: Bytes!
  to: Bytes!
  splitBy: [Bytes!]!
  splitAmounts: [BigInt!]!
  expenseIndex: BigInt!
  blockTimestamp: BigInt!
  transactionHash: Bytes!
}

The mapping handler function

export function handlePaymentExpenseCreated(
  event: PaymentExpenseCreatedEvent
): void {
  const id: string = getIdFromParams(event.params.param0, event.params.param4);
  let activeExpense = ActiveExpense.load(id);
  let newExpense = new PaymentExpenseCreated(id);

  if (!activeExpense) {
    activeExpense = new ActiveExpense(id);
  }

  newExpense.payer = event.params.param0;
  activeExpense.payer = event.params.param0;

  newExpense.to = event.params.param1;
  activeExpense.to = event.params.param1;

  // two different methods of assinging type Address[] to type Bytes[]
  const splitAddresses = event.params.param2.map<Bytes>(
    (address: Bytes) => address
  );
  newExpense.splitBy = splitAddresses;
  activeExpense.splitBy = changetype<Bytes[]>(event.params.param2);

  newExpense.splitAmounts = event.params.param3;
  activeExpense.splitAmounts = event.params.param3;

  newExpense.expenseIndex = event.params.param4;
  activeExpense.expenseIndex = event.params.param4;

  newExpense.blockTimestamp = event.block.timestamp;
  activeExpense.blockTimestamp = event.block.timestamp;

  newExpense.transactionHash = event.transaction.hash;
  activeExpense.transactionHash = event.transaction.hash;

  newExpense.save();
  activeExpense.save();
}

Subgraph yaml file

specVersion: 0.0.5
schema:
  file: ./schema.graphql
dataSources:
  - kind: ethereum
    name: DeSplit
    network: goerli
    source:
      address: "0xA74c0C03A05B94a67FDc09351b312f122308335d"
      abi: DeSplit
      startBlock: 8402740
    mapping:
      kind: ethereum/events
      apiVersion: 0.0.7
      language: wasm/assemblyscript
      entities:
        - ExpenseSettled
        - PaymentExpenseCreated
      abis:
        - name: DeSplit
          file: ./abis/DeSplit.json
      eventHandlers:
        - event: ExpenseSettled(address,address,uint256,uint256)
          handler: handleExpenseSettled
        - event: PaymentExpenseCreated(address,address,address[],uint256[],uint256)
          handler: handlePaymentExpenseCreated
      file: ./src/de-split.ts

The event emitted from the contract and link to the contract

emit PaymentExpenseCreated(
            msg.sender,
            _to, //address
            _splitBy, //address[]
            _splitAmount, // uint256[]
            expenses.length - 1 //uint256
        );

https://goerli.etherscan.io/address/0xA74c0C03A05B94a67FDc09351b312f122308335d

2
  • Hey, do you have the definition of the handler in the subgraph.yaml?
    – donoso.eth
    Jan 31, 2023 at 5:55
  • Hi, I have added the yaml code to the question.
    – Gokul
    Feb 1, 2023 at 6:04

1 Answer 1

0

enter image description hereenter image description here It took me two days to solve the same error. First of all, the event on your contract has no parameter name, which makes it impossible for the subgraph to map accurately. If you can't change the contract, you can try another method, manually mapping it to your subgraph event by modifying the abi in the abis/ folder.

3
  • Hey thank you so much for taking the time. I will make the changes and let you know if it works. Looks a like stupid mistake on my part.
    – Gokul
    Feb 2, 2023 at 17:06
  • Yo champ, you were bang on right. Modifying the ABI fixed it. Thank you once again. This error help me up for a good week.
    – Gokul
    Feb 3, 2023 at 6:03
  • glad to help! have a good day
    – pakyan luo
    Feb 7, 2023 at 14:59

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.