Skip to content

freight-trust/truenft

Repository files navigation

TrueNFT - B2B NFT Protocol

Overview

TrueNFT enables B2B Messages to be tokenized either through EDI or XML Mappings and Data Ingestion

TrueNFT Protocol Diagram

Valid Server Setup

  1. Deploy the NFT and Master Proxy contracts

  2. Deploy the Universal Proxy contract with the Master Proxy’s address and an admin address (this should be a human account) as input

  3. Deploy the Controller contract with the Universal Proxy’s address and an admin address (the same address as in step 2) an input

  4. Call changeController through the Universal Proxy from the admin address. The controller should be changed to the controller address deployed in step

Steps 1-3 cannot be performed through the API. Step 4 can if the controller_address is originally set to equal the universal_address. This solution is not ideal, so all of the steps 1-4 should be completed during the server setup.

Security & Development

These smart contracts will need to be updated for gas efficiency and to verify their security in the upcoming weeks.

The basic smart contract implementation is a functional set of smart contracts that will meet the implementation needs of any company using EDI X12/EDIFACT.

API Contract Testing

  • The continuous integration for github is a script that will run the postman and truffle tests on new commits added to the github repository.

  • The truffle tests are a set of javascript unit tests that will verify the modular properties of the codebase to ensure that it always meets the intention of the smart contract architecture. They are designed to have near-complete code coverage and thus should prevent most bugs.

  • The postman api unit tests are a set of tests for each api endpoint that verify that the endpoints will reject on invalid inputs and return the right data types.

In combination with the truffle tests, the postman tests will verify the integrity of the whole codebase.

The javascript endpoint implementation of the endpoints extends the test endpoints from last week. Now, in addition to data sanitation and returning proper values, they will parse the input data, format transactions and make ethereum calls through the infura web3. The new endpoints will also properly validate Corporate signatures of the nonce which protects admin transactions.

Usage

SEE API

Deployments

Roadmap

Development Dates

GraphQL

2020 Q4

Gas Optimizations

2020 Q4

Composability

2020 Q4

Abstract
API reference for the Freight Trust dApp which allows recording, transfering and signing of EDI-based documents such as bills of lading or warehouse receipts.

Endpoints

Default

getNonce

GET /getNonce

Returns the current message Freight Trust needs to sign to verify their next post request

Description
Parameters
Return Type
Content Type
  • application/json

Responses
Table 1. http response codes
Code Message Datatype

200

Successful query

ApiResponse

428

Request Timeout

<<>>

Samples

ERC721Token

approve

POST /nft/approve/

Change or reaffirm the approved address for an NFT

Description
Parameters
Body Parameter
Name Description Required Default Pattern

auth

The Freight Trust signature of the nonce Auth

X

Query Parameters
Name Description Required Default Pattern

approved

The address being approved

X

null

tokenId

The id of the token to be approved

X

null

Return Type
Content Type
  • application/json

Responses
Table 2. http response codes
Code Message Datatype

200

Successful Approve

ApiResponse

420

Bad Request

<<>>

428

Request Timeout

<<>>

Samples

balanceOf

GET /nft/balanceOf/

Count all NFTs assigned to an owner

Description
Parameters
Query Parameters
Name Description Required Default Pattern

owner

The address of the owner

X

null

Return Type
Content Type
  • application/json

Responses
Table 3. http response codes
Code Message Datatype

200

Successful Query

ApiResponse

420

Bad Request

<<>>

428

Request Timeout

<<>>

Samples

createRecord

POST /nft/createRecord/

Creates a new record

Description

Allows Freight Trust to create a record with the signature of the owner and of the participant.

Parameters
Body Parameter
Name Description Required Default Pattern

auth

InlineObject1

X

Query Parameters
Name Description Required Default Pattern

recordID

The identifying hash of the record

X

null

owner

The owner of the record

X

null

participant

The address of the participant in the record

X

null

Return Type
Content Type
  • application/json

Responses
Table 4. http response codes
Code Message Datatype

200

Successful Creation

ApiResponse

420

Bad Request

<<>>

428

Request Timeout

<<>>

Samples

getApprovedById

GET /nft/getApproved/

Get the approved address for a single NFT

Description

The approved address for this NFT, or the zero address if there is none

Parameters
Query Parameters
Name Description Required Default Pattern

tokenId

The NFT to find the approved address for

X

null

Return Type
Content Type
  • application/json

Responses
Table 5. http response codes
Code Message Datatype

200

Successful Query

ApiResponse

420

Bad Request

<<>>

428

Request Timeout

<<>>

Samples

isApprovedForAll

GET /nft/isApprovedForAll/

Query if an address is an authorized operator for another address

Description

True if operator is an approved operator for owner, false otherwise

Parameters
Query Parameters
Name Description Required Default Pattern

owner

The address that owns the NFTs

X

null

operator

The address that acts on behalf of the owner

X

null

Return Type
Content Type
  • application/json

Responses
Table 6. http response codes
Code Message Datatype

200

Successful Query

ApiResponse

420

Bad Request

<<>>

428

Request Timeout

<<>>

Samples

name

GET /nft/name

Returns the token contract’s name

Description
Parameters
Return Type
Content Type
  • application/json

Responses
Table 7. http response codes
Code Message Datatype

200

Successful query

ApiResponse

428

Request Timeout

<<>>

Samples

ownerOf

GET /nft/ownerOf/

Find the owner of an NFT

Description
Parameters
Query Parameters
Name Description Required Default Pattern

tokenId

The Id of the token in question

X

null

Return Type
Content Type
  • application/json

Responses
Table 8. http response codes
Code Message Datatype

200

Successful Query

ApiResponse

420

Bad Request

<<>>

428

Request Timeout

<<>>

Samples

safeTransferFrom

POST /nft/safeTransferFrom/

Transfers the ownership of an NFT from one address to another address

Description
Parameters
Body Parameter
Name Description Required Default Pattern

auth

The Freight Trust signature of the nonce Auth

X

Query Parameters
Name Description Required Default Pattern

from

The sender of the transfer

X

null

to

The recipient of the transfer

X

null

tokenId

The id of the token to be transferred

X

null

extraData

Optional data to be sent with the transaction

-

null

Return Type
Content Type
  • application/json

Responses
Table 9. http response codes
Code Message Datatype

200

Successful Transfer

ApiResponse

420

Bad Request

<<>>

428

Request Timeout

<<>>

Samples

setApprovalForAll

POST /nft/setApprovalForAll/

Allows Freight Trust to issue univeral approval

Description

Enable or disable approval for a third party (operator) to manage all of Freight Trust’s assets

Parameters
Body Parameter
Name Description Required Default Pattern

auth

The Freight Trust signature of the nonce Auth

X

Query Parameters
Name Description Required Default Pattern

operator

Address to add to the set of authorized operators

X

null

approved

True if the operator is approved, false to revoke approval

X

null

Return Type
Content Type
  • application/json

Responses
Table 10. http response codes
Code Message Datatype

200

Successful Approve

ApiResponse

420

Bad Request

<<>>

428

Request Timeout

<<>>

Samples

signedTransfer

POST /nft/signedTransfer/

Signed Transfer

Description

Allows Freight Trust to sign and transfer a ERC721 token on the behalf of its holder

Parameters
Body Parameter
Name Description Required Default Pattern

auth

InlineObject

X

Query Parameters
Name Description Required Default Pattern

from

The sender of the transfer

X

null

to

The recipient of the transfer

X

null

tokenId

The id of the token to be transferred

X

null

data

Optional data to be sent with the transaction

-

null

Return Type
Content Type
  • application/json

Responses
Table 11. http response codes
Code Message Datatype

200

Successful Transfer

ApiResponse

420

Bad Request

<<>>

428

Request Timeout

<<>>

Samples

supportsInterfaceById

GET /nft/supportsInterface/

Returns an interface’s support status

Description
Parameters
Query Parameters
Name Description Required Default Pattern

interfaceId

The Id of the interface to check

X

null

Return Type
Content Type
  • application/json

Responses
Table 12. http response codes
Code Message Datatype

200

Successful Query

ApiResponse

420

Bad Request

<<>>

428

Request Timeout

<<>>

Samples

symbol

GET /nft/symbol

Returns the token contract’s symbol

Description
Parameters
Return Type
Content Type
  • application/json

Responses
Table 13. http response codes
Code Message Datatype

200

Successful query

ApiResponse

428

Request Timeout

<<>>

Samples

tokenByIndex

GET /nft/tokenByIndex/

Returns the token identifier of the index-th nft tracked by the contract

Description
Parameters
Query Parameters
Name Description Required Default Pattern

index

A counter less than `totalSupply()`

X

null

Return Type
Content Type
  • application/json

Responses
Table 14. http response codes
Code Message Datatype

200

Successful Query

ApiResponse

420

Bad Request

<<>>

428

Request Timeout

<<>>

Samples

tokenOfOwnerByIndex

GET /nft/tokenOfOwnerByIndex/

Returns the token identifier of the index-th nft assigned to the owner

Description
Parameters
Query Parameters
Name Description Required Default Pattern

owner

The address of the owner

X

null

index

The index of the nft assigned to the owner

X

null

Return Type
Content Type
  • application/json

Responses
Table 15. http response codes
Code Message Datatype

200

Successful Query

ApiResponse

420

Bad Request

<<>>

428

Request Timeout

<<>>

Samples

tokenURIById

GET /nft/tokenURI/

Enumerate NFTs assigned to an owner

Description
Parameters
Query Parameters
Name Description Required Default Pattern

tokenId

X

null

Return Type
Content Type
  • application/json

Responses
Table 16. http response codes
Code Message Datatype

200

Successful Query

ApiResponse

420

Bad Request

<<>>

428

Request Timeout

<<>>

Samples

totalSupply

GET /nft/totalSupply

An API endpoint to get the total supply of tokens in the ERC721 contract

Description

Returns the total supply of Non fungible tokens

Parameters
Return Type
Content Type
  • application/json

Responses
Table 17. http response codes
Code Message Datatype

200

Successful query

ApiResponse

428

Request Timeout

<<>>

Samples

transferFrom

POST /nft/transferFrom/

Transfer ownership of an NFT without safety checks

Description

Allows Freight Trust to tranfer tokens unsafely — 

THE CALLER IS RESPONSIBLE TO CONFIRM THAT IS CAPABLE OF RECEIVING NFTS OR ELSE THEY MAY BE PERMANENTLY LOST

Parameters
Body Parameter
Name Description Required Default Pattern

auth

The Freight Trust signature of the nonce Auth

X

Query Parameters
Name Description Required Default Pattern

from

The sender of the transfer

X

null

to

The recipient of the transfer

X

null

tokenId

The id of the token to be transferred

X

null

Return Type
Content Type
  • application/json

Responses
Table 18. http response codes
Code Message Datatype

200

Successful Transfer

ApiResponse

420

Bad Request

<<>>

428

Request Timeout

<<>>

Samples

versionRecord

POST /nft/versionRecord/

Versions a record for Freight Trust

Description

Allows Freight Trust to version one of the records they own.

Parameters
Body Parameter
Name Description Required Default Pattern

auth

The Freight Trust nonce signature to verify this action Auth

X

Query Parameters
Name Description Required Default Pattern

current

The identifying hash of the record

X

null

new

The new identifying hash of the record

X

null

Return Type

-

Responses
Table 19. http response codes
Code Message Datatype

200

Successful Edit

<<>>

420

Bad Request

<<>>

428

Request Timeout

<<>>

Samples

versionRecordSigned

POST /nft/versionRecord/signed/

Versions a record for the owner

Description

Allows Freight Trust to version a record for the owner using the owner’s signature.

Parameters
Body Parameter
Name Description Required Default Pattern

auth

InlineObject2

X

Query Parameters
Name Description Required Default Pattern

current

The identifying hash of the record

X

null

new

The new identifying hash of the record

X

null

owner

The owner of the record which will be updated

-

null

Return Type

-

Responses
Table 20. http response codes
Code Message Datatype

200

Successful Editing

<<>>

420

Bad Request

<<>>

428

Request Timeout

<<>>

Samples

ProxyAndUpgrade

changeController

POST /proxy/changeController/

Sets the the new controller address

Description

Sets the new controller address.

Parameters
Body Parameter
Name Description Required Default Pattern

auth

The Freight Trust signature of the nonce Auth

X

Query Parameters
Name Description Required Default Pattern

newController

The new controller address

X

null

Return Type
Content Type
  • application/xml

  • application/json

Responses
Table 21. http response codes
Code Message Datatype

200

Successfuly Changed

ApiResponse

425

Invalid Input

<<>>

Samples

changeMaster

POST /proxy/changeMaster/

Sets the address of Function

Description

Sets address that is delegate called to run a function’s logic. This function must be called with an signed nonce from the Freight Trust account in the https body.

Parameters
Body Parameter
Name Description Required Default Pattern

auth

The Freight Trust signature of the nonce Auth

X

Query Parameters
Name Description Required Default Pattern

newMaster

The new master address

X

null

Return Type
Content Type
  • application/xml

  • application/json

Responses
Table 22. http response codes
Code Message Datatype

200

Successfuly Changed

ApiResponse

425

Invalid Input

<<>>

Samples

getControler

GET /proxy/getControler

Gets address of the controler Contract

Description

Gets the address of the controler contract.

Parameters
Return Type
Content Type
  • application/xml

  • application/json

Responses
Table 23. http response codes
Code Message Datatype

200

successful operation

ApiResponse

Samples

getMaster

GET /proxy/getMaster

Gets address of the Master Contract

Description

Gets the address of the master contract.

Parameters
Return Type
Content Type
  • application/xml

  • application/json

Responses
Table 24. http response codes
Code Message Datatype

200

successful operation

ApiResponse

Samples

getTarget

GET /proxy/getTarget/

Gets address of Function

Description

Gets address that is delegate called to run a function’s logic.

Parameters
Query Parameters
Name Description Required Default Pattern

id

The function selector the return the target of

X

null

Return Type
Content Type
  • application/xml

  • application/json

Responses
Table 25. http response codes
Code Message Datatype

200

successful operation

ApiResponse

425

Invalid Input

<<>>

Samples

getUniversalProxy

GET /proxy/getUniversalProxy

Gets address of the Universal Proxy Contract

Description

Gets the address of the Universal Proxy contract.

Parameters
Return Type
Content Type
  • application/xml

  • application/json

Responses
Table 26. http response codes
Code Message Datatype

200

successful operation

ApiResponse

Samples

pause

POST /proxy/pause

Pauses the execution

Description

Calls the pause method in the universal proxy, blocking any state changes while Freight Trust’s Network Operations Group updates.

Parameters
Body Parameter
Name Description Required Default Pattern

auth

The Freight Trust signature of the nonce Auth

X

Return Type
Content Type
  • application/xml

  • application/json

Responses
Table 27. http response codes
Code Message Datatype

200

Successfuly Paused

ApiResponse

425

Invalid Input

<<>>

Samples

setTarget

POST /proxy/setTarget/

Sets the address of Function

Description

Sets address that is delegate called to run a function’s logic. This function must be called with an signed nonce from the Freight Trust account in the https body.

Parameters
Body Parameter
Name Description Required Default Pattern

auth

The Freight Trust signature of the nonce Auth

X

Query Parameters
Name Description Required Default Pattern

id

Function selector whose target to change.

X

null

target

The address to set the function too

X

null

Return Type
Content Type
  • application/xml

  • application/json

Responses
Table 28. http response codes
Code Message Datatype

200

Successfuly Changed

ApiResponse

425

Invalid Input

<<>>

Samples

Models

ApiResponse

Field Name Required Type Description Format

code

Integer

int32

type

String

message

String

Auth

Field Name Required Type Description Format

signature

X

String

InlineObject

Field Name Required Type Description Format

freightTrustAuth

auth

senderAuth

auth

InlineObject1

Field Name Required Type Description Format

freightTrustAuth

auth

ownerAuth

auth

partAuth

auth

InlineObject2

Field Name Required Type Description Format

freightTrustAuth

auth

ownerAuth

auth

License

Copyright 2020 © FreightTrust and Clearing Corporation All Rights Reserved - https://freighttrust.com

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/