Block에 ipfs cid 값 기록 관련의 건

안녕하세요
ipfs.add를 통해서 cid 값을 받아 왔는데, cid 값을 block에 기록을 하고자 합니다.

cid값은 잘 받아오고, signTransaction으로 rawTransaction 값도 잘 받아 옵니다 .하지만, sendTransaction을 보내면 Error: evm: execution reverted 에러가 발생합니다.

혹시 제가 잘못진행 한 것일까요??

  const buffer = Buffer.from("hello wrold");
    const response = await caver.ipfs.add(buffer.buffer);
    const hex = caver.ipfs.toHex(response);

    console.log("send file CID :", response);

    let senderRawTransaction = "";
    try {
      //@ts-ignore
      const { rawTransaction } = await caver.klay.accounts.signTransaction(
        {
          type: "FEE_DELEGATED_SMART_CONTRACT_EXECUTION",
          from: klaytn.selectedAddress,
          to: "0x92c73e30b4dd72db7aaaae9efd82f8140349ce2d",
          data: hex,
          gas: "500000",
        },
        privateKey
      );
      senderRawTransaction = rawTransaction;
      console.log(senderRawTransaction);
    } catch (error) {
      console.log(">>>>>>>>>>", error);
    }

    try {
      if (senderRawTransaction) {
        const result = await caver.klay.sendTransaction({
          senderRawTransaction: senderRawTransaction,
          feePayer: feePayer.address,
        });
        console.log("!!!!!!!", result);
      }
    } catch (error) {
      console.log("@@@###", error);
    }

error

Error: evm: execution reverted
 {
  "blockHash": "0xb5921a82fa69327549b216df1c4abc346506c70b6f4bf1566adbc40ab4ee4667",
  "blockNumber": 85938670,
  "contractAddress": null,
  "feePayer": "0x5fabbb43b9d1615ae08c412f8cc5e40197d274db",
  "feePayerSignatures": [
    {
      "V": "0x7f5",
      "R": "0xb4b6a870aabfb8a8828f1a6bffa60588f4412bac328ac8baea3dea0c59215d2c",
      "S": "0x4a275512d04ff161b2e8b49c8f05de71a092bb224b58133a6b7e84ae15f4b8f6"
    }
  ],
  "from": "0x1421dddfa9305c5e68b52357a0b8f95baabe6592",
  "gas": "0x7a120",
  "gasPrice": "0xae9f7bcc00",
  "gasUsed": 34613,
  "input": "0x1220ca85c3ae715df72fb538e1c34daa56172690b2b44b6d6c44759990e545ab47e4",
  "logs": [],
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "nonce": "0xa5",
  "senderTxHash": "0xeaf8250b9dd5bf436a3f8671d9ce5de61356d81b352bc42abc2a4e29caca9202",
  "signatures": [
    {
      "V": "0x7f6",
      "R": "0xf01fbf9dc7d562e5cb78543bfb805e814fbc5f467d26d8e778ace40df404d1f4",
      "S": "0x685ba8b58a58656f8dd6e5db3bfec146714ca70b8639b2c365bd76a6b3fb43c2"
    }
  ],
  "status": false,
  "to": "0x92c73e30b4dd72db7aaaae9efd82f8140349ce2d",
  "transactionHash": "0x089f02c1f2ea9036382d1310cec40c95edd09e4bc65e816707bdd777d2faa2e6",
  "transactionIndex": 2,
  "txError": "0x9",
  "type": "TxTypeFeeDelegatedSmartContractExecution",
  "typeInt": 49,
  "value": "0x0"
}
    at checkForNormalTx (index.js:771:1)
    at index.js:648:1

작성자님께서 트랜잭션을 실행하실때, 아래와 같이 Smart contract execution을 실행하셨기 때문에
to 주소와 입력하는 데이터는 실행할 컨트랙트와 그 컨트랙트에서 호출하실 method의 4byte code를 포함한 input data형태로 제공해주셔야 합니다.

방법은 일반 트랜잭션인 Value transfer에서 data만 추가 기록하시거나.
컨트랙트에 해당 CID를 저장하는 property와 이에 상응하는 setter와 getter method를 설정하셔서 사용하시기를 권장드립니다.

이 경우 일반적인 컨트랙트 메소드 호출방법으로 기록 가능하십니다. 다만 입력값의 데이터타입 사용에만 유의하시면 될것으로 생각됩니다.

답변되셨길 바랍니다. 감사합니다.

2개의 좋아요

답변 감사합니다. 별도의 transaction 대신 smart contract getter setter 함수 추가하여 문제 해결 했습니다.

1개의 좋아요