Skip to content

Agent APIs

Latest
Compare
Choose a tag to compare
@aggre aggre released this 02 Feb 04:11
· 974 commits to main since this release

The new API: Agent APIs

Dev Kit used to provide only low-level APIs, so you needed to understand the differences in interfaces between networks.

With Agent APIs, there is only one API to know for one use case with Agent APIs. Agent APIs create and cache the appropriate contract instances from the given provider. positionsCreate API to start staking is the first one.

The following code is an example of staking 100 DEV on a Property Tokens:

import { positionsCreate } from '@devprotocol/dev-kit/agent'

positionsCreate({
    provider: ethersProvider,
    destination: '0x.....',
    amount: '100000000000000000000'
})

Destructive change in return values

APIs that mutate the state of contracts have traditionally used Promise<boolean> as the return value. Since version 6.x, their return value has changed to Promise<TransactionResponse>.

The APIs where affected are as follows:

  • Dev.transfer
  • Dev.approve
  • Dev.transferFrom
  • Dev.deposit
  • Lockup.withdrawByPosition
  • Lockup.withdraw
  • Lockup.depositToPosition
  • Lockup.migrateToSTokens
  • MarketFactory.create
  • Property.transfer
  • Property.approve
  • Property.transferFrom
  • Property.changeName
  • Property.changeSymbol
  • PolicyFactory.create
  • STokens.freezeTokenURI
  • STokens.setTokenURIImage
  • Withdraw.withdraw