> For the complete documentation index, see [llms.txt](https://fibonacci.gitbook.io/whitepaper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fibonacci.gitbook.io/whitepaper/socialx-code.md).

# SocialX  code

The following is the SocialX social protocol contract, taking solidity as an example. The concise code below implements the social protocol. In the future, it will open source implementations of other contract languages such as Bitcoin script, Move language, and become the cornerstone of cross-chain social networking.&#x20;

<br>

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.18;

contract SocialX {

&#x20;  struct App {

&#x20;      uint256 topics;

&#x20;      uint256 appends;

&#x20;      uint256 repays;

&#x20;  }

&#x20;  uint256 public immutable LOCATION\_ID;

&#x20;  mapping(uint256 => App) public apps;

&#x20;  event Create(uint256 indexed app\_id, uint256 topic\_id);

&#x20;  event Append(uint256 indexed app\_id, uint256 append\_id);

&#x20;  event Reply(uint256 indexed app\_id, uint256 repay\_id);

&#x20;  event Tags(uint256 indexed app\_id);

&#x20;  event Follow(uint256 indexed app\_id);

&#x20;  constructor(uint256 location\_id) {

&#x20;      LOCATION\_ID = location\_id;

&#x20;  }

&#x20;  // @param sign\_data Consists of {SignTypeId}{SignAddress}{SignMessage}{SignResult} padded.  abi.encode(\['uint256', 'address', 'string', 'string'],\[SignTypeId,SignAddress,SignMessage,SignResult])

&#x20;  function create(uint256 app\_id, bytes calldata sign\_data, uint256 node\_id, string calldata title, string calldata content) external {

&#x20;      emit Create(app\_id, ++apps\[app\_id].topics);

&#x20;  }

&#x20;  function append(uint256 app\_id, bytes calldata sign\_data, uint256 target\_location\_id, string calldata topic\_hash, string calldata content) external {

&#x20;      emit Append(app\_id, ++apps\[app\_id].appends);

&#x20;  }

&#x20;  function reply(uint256 app\_id, bytes calldata sign\_data, uint256 target\_location\_id, string calldata topic\_hash, string calldata content) external {

&#x20;      emit Reply(app\_id, ++apps\[app\_id].repays);

&#x20;  }

&#x20;  function reply(uint256 app\_id, bytes calldata sign\_data, uint256 target\_location\_id, string calldata topic\_hash, string calldata content, uint256 target\_reply\_location\_id, string calldata reply\_hash) external {

&#x20;      emit Reply(app\_id, ++apps\[app\_id].repays);

&#x20;  }

&#x20;  function tags(uint256 app\_id, bytes calldata sign\_data, bytes\[] calldata data) external {

&#x20;      emit Tags(app\_id);

&#x20;  }

&#x20;  function follow(uint256 app\_id, bytes calldata sign\_data, address target\_address, bool follow\_status, string calldata remark) external {

&#x20;      emit Follow(app\_id);

&#x20;  }

}

For more details, please refer to:  <https://github.com/Social-xxx/contract-socialx>

<br>

<br>

<br>
