Based on Ts.ED framework
See Ts.ED project for more information.
Important! Ts.ED requires Node >= 10, Express >= 4 and TypeScript >= 3.
# install dependencies
$ npm install
# serve
$ npm run start
# build for production
# NOTE: currently smart contract panic messages won't be returned in prod mode
$ npm run build
$ npm run start:prodCurrently all transactions are signed by accounts from local unencrypted JSON key store (by default ~/.near-credentials) just like near-cli.
You can config the path for keystore folder in config.keyStorePath
-
Call contract method
- method:
POST - URL:
/:network_id/contract/:contract_id/:method_namenetwork_id:mainnetortestnetcontract_id: Contract ID(address) e.g.my-nft.testnetmethod_name: Method name e.g.nft_transfer
- Body parameters:
account_id: Caller account id. (Account private key will be read from local keyStore folder.)args: Method argumentsgas: Gas amount (e.g.300 Tgas,1 Ggas), see near-unitsdeposit: Attached NEAR deposit (e.g.10N,1yN), see near-units
- method:
-
View contract method
- method:
GET - URL:
/:network_id/contract/:contract_id/:method_namenetwork_id:mainnetortestnetcontract_id: Contract ID(address) e.g.my-nft.testnetmethod_name: Method name e.g.nft_transfer
- parameters:
- view args can be provided through either JSON body or url query.
- If body is provided, url query will be ignored.
- method:
-
GET/:network_id/nep171/:contract_id/nft_token- Get one NFT
- Query Params
token_id: token id
-
POST/:network_id/nep171/:contract_id/nft_transfer- Transfer an NFT
- Body Params
*account_id: calling account id*deposit: deposit, MUST be1yNargs*receiver_id: receiver id*token_id: token idapproval_id: approval idmemo: memo string
To add new endpoints for any NEP standards. You can take neps/nep171.ts as an example.
- Create a new file named by NEP standard (e.g.
nep141.ts) in neps folder. - Export a dictionary of NEP type, which should describe the standard name, view methods and change methods.
- For each view/change method, define its name and call arguments.