Tax reports on Internet Computer

Hi @LefterisJP and @e274426380 ,

Glad to see theres some interest in creating a solution for this! I’m one of the engineers on the NNS team and can provide some insight on the APIs and source of some data. Hopefully this can serve as a base for you and the community to build these dapps.

I’ll answer @LefterisJP 's questions here, but perhaps if this requires a longer form discussion I will consider a blog post. Note, just like @peterparker said, my team also has a backlog item for recording neuron operations for audits so some information is not historically accessible. Rest assured though, I believe most tax information can be tracked via ledger transactions.

  • What neurons belong to a given address?

For both the NNS and SNS, you can identify a neuron by its account on the respective ledger (NNS uses the ICP ledger to back NNS neurons, while SNS neurons are backed on the SNSes ledger). The NNS Neuron uses a random number for its id while the id of an SNS neuron is the subaccount used to determine its account.

The account of a neuron is calculated as follows:

For ICP Ledger, the AccountIdentifier is a 32-byte array that is a hash of a Principal and subaccount. The Principal is the NNS governance canister id (rrkah-fqaaa-aaaaa-aaaaq-cai) and the subaccount is a hash of the user’s principal id and a unique memo (the memo allows for a principal to own multiple neurons).

AccountIdentifier=hash(governance_canister_id, hash(user_principal, unique_memo))

For SNS Ledgers, the Account is an ICRC construct that removed the first hashing function, and is parameterized on each individual SNS Governance canister id.

Account=(sns_governance_canister_id, hash(user_principal, memo))
  • Current balance in ICP of a number of neurons

This is also variable. You can look directly at the ICP ledger or SNS ledger account, but that might not paint the full picture. This should be combined with looking directly at the neuron and inspecting its maturity balance and its neuron_fees. In the SNS, all of this information is public, but in the NNS this information is privileged. If this is a dapp, the dapp canister can be added as a hotkey to each neuron to collect this information.

I’d also be happy to provide the APIs to inspect neurons.

  • Current balance in ICP of a number of addresses

This is already possible by getting the balance from a ledger once you know the identifier.

  • Given an address query all historical actions. Mainly regarding neurons and voting. Such as extending age of a neuron, disbursing, dissolving, spawning etc

Some of this Neuron information can be built by polling the neuron with the right permission, but a historical audit trail is not currently available. Some of this information can be detected by inspecting the ledger account of a neuron. The ICP Index will be helpful to inspect historic ICP transactions. I’d be happy to expand on that if needed.

  • Generally all other information you would need for proper tracking and accounting.
    Such as how much ICP they have and what neurons they own?

Tracking some of this information is possible with the consent of the user. I think I’ve outlined some of the methods to achieve this above, but if there are more precise requests for how find this data I could add more detail.

5 Likes