open-index/open-npm huggingface dataset:
npm package: @iota/is-shared-modules
Description: Shared modules of the Integration Service.
Author: Dominic Zettl
Latest version: 0.2.3

# IOTA Integration Services Shared Modules
This packages contains modules used in the [SSI-Bridge](https://github.com/iotaledger/integration-services/tree/develop/api/ssi-bridge), [Audit-Trail](https://github.com/iotaledger/integration-services/tree/develop/api/audit-trail-gw) and [IS-Client](https://www.npmjs.com/package/@iota/is-client).

****This package should only be installed if access to the Integration Service's models is needed.****
npm package: @iota/iscmagic
Description: The Magic contract is an EVM contract deployed by default on every ISC chain, in the EVM genesis block, at address 0x1074000000000000000000000000000000000000. The implementation of the Magic contract is baked-in in the evm core contract); i.e. it is not a
Author: Iota Smart Contracts
Latest version: 2.0.3-rc.1

# @iota/iscmagic

The Magic contract is an EVM contract deployed by default on every ISC chain, in the EVM genesis block, at address 0x1074000000000000000000000000000000000000. The implementation of the Magic contract is baked-in in the [evm](https://wiki.iota.org/shimmer/smart-contracts/guide/core_concepts/core_contracts/evm/) [core contract](https://wiki.iota.org/shimmer/smart-contracts/guide/core_concepts/core_contracts/overview/); i.e. it is not a pure-Solidity contract.

The Magic contract has several methods, which are categorized into specialized interfaces: ISCSandbox, ISCAccounts, ISCUtil and so on. You can access these interfaces from any Solidity contract by importing this library.

The Magic contract also provides proxy ERC20 contracts to manipulate ISC base tokens and native tokens on L2.

Read more in the [Wiki](https://wiki.iota.org/shimmer/smart-contracts/guide/evm/magic/).

## Installing @iota/iscmagic contracts

The @iota/iscmagic contracts are installable via __NPM__ with 

```bash
npm install @iotago/iscmagic
```

After installing `@iota/iscmagic` you can use the functions by importing them as you normally would.

```ts
pragma solidity >=0.8.5;

import "@iotago/iscmagic/ISC.sol";

contract MyEVMContract {
    event EntropyEvent(bytes32 entropy);

    // this will emit a "random" value taken from the ISC entropy value
    function emitEntropy() public {
        bytes32 e = ISC.sandbox.getEntropy();
        emit EntropyEvent(e);
    }
}

```
npm package: @iota/iscutils
Description: The iscutils package contains various utility methods to simplify the interaction with the IOTA Magic contract.
Author: Iota Smart Contracts
Latest version: 2.0.3-rc.1

# @iota/iscutils

The iscutils package contains various utility methods to simplify the interaction with the IOTA Magic contract. This utility library is designed to be used with the [@iota/iscmagic](https://www.npmjs.com/package/@iota/iscmagic/) npm package.

The Magic contract, an EVM contract, is deployed by default on every ISC chain. It has several methods, accessed via different interfaces like ISCSandbox, ISCAccounts, ISCUtil and more. These can be utilized within any Solidity contract by importing the `@iota/iscmagic` library.

For further information on the Magic contract, check the [Wiki](https://wiki.iota.org/shimmer/smart-contracts/guide/evm/magic/).

## Installing @iota/iscutils contracts

The @iota/iscutils contracts are installable via __NPM__ with

```bash
npm install @iotago/iscutils
```

After installing `@iota/iscutils` you can use the functions by importing them as you normally would.

## Utilities

### PRNG

A pseudorandom number generator is available by importing `prng.sol`. Its required seeding process simply depends on a random 32-byte value, and each invocation of the `getRandomNumber()` method will generate an algorithmically determined number, based on the initial seed and numbers generated prior. Its deterministic nature makes it ideal for accomplishing predictable outcomes during testing.

The recommended source for the seed value is attained via the `getEntropy()` method from the ISC sandbox (via the magic contract.) This call yields random bytes drawn from the existing consensus state. Although it is distinctive for each block, it remains the same between immediate calls processed within the same block. Therefore, in order to introduce randomness within a block, this utility comes into play, providing pseudorandom values throughout the block process, buffering the immutable nature of `getEntropy()` within the same block.

#### Example PRNG usage

```solidity
pragma solidity >=0.8.5;

import "@iota/iscmagic/ISC.sol";
import "@iota/iscutils/prng.sol";

contract MyEVMContract {
    using PRNG for PRNG.PRNGState;

    event PseudoRNG(uint256 value);
    event PseudoRNGHash(bytes32 value);
    
    PRNG.PRNGState private prngState;

    function emitValue() public {
        bytes32 e = ISC.sandbox.getEntropy();
        prngState.seed(e);
        bytes32 randomHash = prngState.generateRandomHash();
        emit PseudoRNGHash(randomHash);
        uint256 random = prngState.generateRandomNumber();
        emit PseudoRNG(random);
        uint256 randomRange = prngState.generateRandomNumberInRange(111, 1111111);
        emit PseudoRNG(randomRange);
    }
}
```