@@ -48,6 +48,7 @@ import { AssetResult, NeverminedService } from '../shared/nevermined/nvm.service
4848import { TransferDto } from './dto/transfer'
4949import { UploadDto } from './dto/upload'
5050import { UploadResult } from './dto/upload-result'
51+ import { formatUnits } from 'viem'
5152
5253export enum UploadBackends {
5354 IPFS = 'ipfs' ,
@@ -254,14 +255,31 @@ export class AccessController {
254255 if ( ! this . backendService . isBackendEnabled ( ) ) {
255256 Logger . log ( `NVM Backend not enabled, skipping tracking transaction in the database` )
256257 } else {
257- const assetPrice = this . nvmService . getAssetPrice ( service ) / 10n ** BigInt ( 4 )
258+ const assetPrice = this . nvmService . getAssetPrice ( service ) . getTotalPrice ( )
259+ const erc20TokenAddress =
260+ this . nvmService . getAssetPrice ( service ) ?. getTokenAddress ( ) ||
261+ this . nvmService . getNevermined ( ) . utils . token . getAddress ( )
262+
263+ let currency : string
264+ let decimals : number
265+ if ( erc20TokenAddress === ZeroAddress ) {
266+ currency = 'ETH'
267+ decimals = 18
268+ } else {
269+ const erc20 = await this . nvmService . getNevermined ( ) . contracts . loadErc20 ( erc20TokenAddress )
270+ currency = await erc20 . symbol ( )
271+ decimals = await erc20 . decimals ( )
272+ }
273+
274+ const priceHighestDenomination = + formatUnits ( assetPrice , decimals )
275+
258276 const assetTx : AssetTransaction = {
259277 assetDid : did . getDid ( ) ,
260278 assetOwner : subscriptionDDO . proof . creator ,
261279 assetConsumer : transferData . nftReceiver ,
262280 txType : 'Mint' ,
263- price : ( Number ( assetPrice ) / 100 ) . toString ( ) ,
264- currency : 'USDC' ,
281+ price : priceHighestDenomination . toString ( ) ,
282+ currency : currency ,
265283 paymentType : 'Crypto' ,
266284 txHash : JSON . stringify ( txs ) ,
267285 metadata : '' ,
0 commit comments